< previous page page_a51 next page >

Page A51
Chapter 4
Case Study Follow-Up
1. Prepare File for Reading, Get Data, Find Weighted Average, Print Weighted Average, and Print Heading are concrete modules. Print Data is an abstract module because it has a submodule below it.
Chapter 5
Exam Preparation Exercises
2. a. No parentheses are needed. b. No parentheses are needed.c. No parentheses are needed. d. ! (q && q)
6. a. 4 b. 2 c. 5 d. 3 e. 1
9. a. If-Then-Else b. If-Then c. If-Then d. If-Then-Else
10. The error message is printed because there is a semicolon after the right brace of a block (compound statement).
13. Yes
Chapter 5
Programming Warm-Up Exercises
2. In the following statement, the outer parentheses are not required but are included for readability.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
available = (numberOrdered <= (numberOnHand numberReserved));
4. In the following statement, the parentheses are not required but are included for readability.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
leftPage = (pageNumber % 2 == 0);
6. if (year % 4 == 0)
       cout << year <<  is a leap year. endl;
   else
   {
       year = year + 4 - year % 4;
       cout << year <<  is the next leap year. << endl;
   }
7. if (age > 64)
       cout << Senior voter;
   else if (age << 18)
       cout << Under age;
   else
       cout << Regular voter;
9. // This is a nonsense program
   if (a > 0)
       if (a << 20)
       {
           cout << A is in range. << endl;
           b = 5;
       }

 
< previous page page_a51 next page >