/////////////////////////////////////////////////////////////////// // // arithmetic.cpp // // Started 1/6/97 by Jeff Ondich // Last modified: 9/16/99 // // 1. Compile and run this program. What does // the operation "%" do? How about "/"? (Try running // the program several times with different input.) // // 2. Now change the type of a and b from "int" // to "double". Recompile. How does the behavior // of "%" change? Get rid of the "%" line and // recompile. How does the behavior of "/" change? // The type "double" is badly named--what does it // mean in this context? // // 3. Suppose you want to "comment out" a block of // code that's bugging you. That is, you want to // make the compiler ignore some code without // actually removing the code from your file. // The /*...*/ style comments give you a convenient // tool for doing this. Try commenting out everything // in main() except for the return(0) statement. // Recompile. What happens, and why? How can you // fix the problem? // // Which style of comments should you use for ordinary // comments? // /////////////////////////////////////////////////////////////////// #include int main( void ) { int a, b; /* This comment is here to cause trouble in number 3 above. Please ignore it. */ cout << "Two integers, please: "; // Does this comment cause trouble? cin >> a >> b; cout << a << " + " << b << " = " << a + b << endl; cout << a << " - " << b << " = " << a - b << endl; cout << a << " * " << b << " = " << a * b << endl; cout << a << " / " << b << " = " << a / b << endl; cout << a << " % " << b << " = " << a % b << endl; return( 0 ); }