Sams Teach Yourself C++ in 21 Days

(singke) #1
17: else
18: cout << “a-b does not equal c: “;
19: return 0;
20: }


  1. Enter the program from Exercise 2; compile, link, and run it. Enter the numbers
    20, 10, and 50. Did you get the output you expected? Why not?

  2. Examine this program and anticipate the output:
    1: #include
    2: using namespace std;
    3: int main()
    4: {
    5: int a = 2, b = 2, c;
    6: if (c = (a-b))
    7: cout << “The value of c is: “ << c;
    8: return 0;
    9: }
    Enter, compile, link, and run the program from Exercise 4. What was the output? Why?


98 Day 4

Free download pdf