// Program file: simpleif.cpp // This program demos if statements #include #include #include using namespace std; int main() { int n1, n2, n3, n4; char c1, c2; clrscr(); cout << "Enter 3 integer numbers and press enter: "; cin >> n1 >> n2 >> n3; cout << "Enter 2 letters and press enter: "; cin >> c1 >> c2; cout << endl << endl; cout << "n1 = " << n1 << " n2 = " << n2 << " n3 = " << n3 << " n4 = " << n4 << endl; cout << "c1 = " << c1 << " c2 = " << c2 << endl << endl; if ( n1 > 5 ) cout << "n1 is greater than 5" << endl; if ( n1 >= n2 ) cout << "n1 is greater than or equal to n2" << endl; else cout << "n1 is not greater than or equal to n2" << endl; if ( n2 < n3 ) { n4 = n1 + n2; cout << "n2 is less than n3"; cout << " and n4 = " << n4 << endl; } else cout << "n2 is not less than n3" << endl; if ( n2 > 1 && n2 < 10) cout << "n2 is in the range of 2-9" << endl; else { cout << "n2 is out of the range of 2-9" << endl; n4 = n2; cout << "n2 = " << n2 << " and n4 = " << n4 << endl; } if ( n1 < n2 || n2 < n3 ) if ( n1 < n2 ) { cout << "n1 is less than n2 but "; cout << "n2 may not be less than n3" << endl; } else cout << "n2 is less than n3" << endl; else { cout << "n1 is not less than n2"; cout << " and n2 is not less than n3" << endl; } if ( c1 == c2 ) cout << "c1 is equal to c2" << endl; if ( c1 != c2 ) cout << "c1 is not equal to c2" << endl; else cout << "c1 is equal to c2" << endl; getch(); return 0; }