// If Else Example #3 C++ Code from CodingMagic.com // Copyright 2008 by Pierre Dufilie IV #include // Include the system() function so we can pause the program #include // Include the printf() function so we can print to the screen int main(void) { // The main function - this is where the program begins running int n; // Declare an instance of an integer variable, n printf("Please enter a number: "); // Use printf to display "Please enter a number: " scanf("%d", &n); // Use scanf to read a number from the console if (n > 1) { // Test to see if n is greater than 1. If so, then run the following code. printf("n is greater than 1!\n"); // Use printf to display "n is greater than 1!" } else { // If the above if statement's condition isn't met, i.e. if n is not greater than 1, then we run the following code. printf("n is not greater than 1.\n"); // Use printf to display "n is not greater than 1." } system("PAUSE"); // Run a system command via system() function to pause execution return 0; // Represents the return value of the program (EXIT_SUCCESS) }