// Ex330.cc // Sec. 3.3 and Sec 3.4 of lecture // Comparisons and logical operations #include main() { bool bi,bj; int i; bi = ( 3 <= 4 ); // Boolean bj = ( 3 > 4 ); // Boolean cout << " 3 <= 4 TRUE = " << bi << endl; cout << " 3 > 4 FALSE = " << bj << endl; // if - statement will be defined in Sec. 4 i = 3; if (i <= 4) { cout << "\n i less or equal 4 \n\n"; } // Equal vs. Assignment i = 2; cout << " i == 3 ist ein Vergleich : " << ( i == 3) << endl; cout << " und beläßt den Wert von i bei " << i << endl; cout << " i = 3 ist eine Zuweisung : " << ( i = 3) << endl; cout << " und ändert den Wert von i in " << i << endl; // Use of wrong expression has side effects i = 2; cout << " AA: i = " << i << endl; if ( i = 3 ) // Assignment i=3 is always true !! { cout << " BB: i = " << i << endl; i = 0; } cout << " CC: i = " << i << endl; // i is always 0 !! }