// Demonstrating using IF statements // with logical operators AND and OR // Week 2 Lecture 3 // Problem 1: Let the user provide you any number, and you must determine if // the number is even or odd. If even, print the number is "EVEN!", if odd, // print the number is "ODD!" // Steps to solve it: // 1. Take the input in from the user: scanf() // 2. To check even, % 2 = 0 // 3. If that is TRUE, then printf "EVEN" // 4. If that is FALSE, then printf "ODD" // Problem 2: Let the user provide you a number 1-100, that you check and decide // how many digits the number has. // PROBLEM 1: #include int main(void){ // Declared a variable number of type int int number; // Initialise it by scanning into it (taking the user input) printf("Enter a number: "); // scanf() returns the number of things that were scanned in // successfully // Declare a variable to hold whatever it is that scanf returns int scanf_return; scanf_return = scanf("%d", &number); printf("The value of scanf_return is %d\n", scanf_return); if (number % 2 == 0){ printf("EVEN!\n"); } else { printf("ODD!\n"); } return 0; }