/////////////////////////////////////////////////////// // // decisions.cpp // // Started 1/6/97 by Jeff Ondich // Last modified: 9/16/99 // // 1. Read through this program and predict its behavior. // Compile it and run it several times with varying // input. Can you get all of the different output // messages? // // 2. One message asks "What do I know about that first number?" // If that message appears, what _do_ you know about the first // number? // // 3. What does "&&" mean (see the "third and fourth // messages" section) in English? Try replacing "&&" // with "||", which means "or". Does the program // behave as expected? (You can test it by entering // two numbers, only one of which is zero). // //////////////////////////////////////////////////////// #include int main( void ) { int a, b; cout << "Please type two integers separated by a space: "; cin >> a >> b; // First message. if( a > b ) cout << "That first number is big!" << endl; else cout << "Gosh, what a small first number." << endl; // Second message. if( a < 0 ) { cout << "Oooh..." << endl; cout << "The first number is also negative." << endl; } else { if( a == 0 ) cout << "The first is 0, my favorite number." << endl; else cout << "What do I know about that first number?" << endl; } // Third and fourth messages, maybe. if( a == 0 && b == 0 ) cout << "Pure Nothingness. Cool." << endl; if( b != 7 ) cout << "I wish the second number were 7." << endl; return( 0 ); }