< previous page page_87 next page >

Page 87
Answers 1. A program must have at least one functionthe main function. 2. Unless your last name is hyphenated, it probably is a valid C++ identifier.
3. const float DELTA = 0.562;
4. const, float
5. int count;
   float sum;
   char letter;
6. toes = 10;
7. a. 9.0 / 5.0
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. 9 / 5 8. 1
9. cout < Programming and Problem Solving with C++ < endl;
10. The answer is 4
11. float annualReceiptsMA;   // Total of monthly cash
                              // receipts in the
                              // Massachusetts store

    or

    float annualReceiptsMA;   /*Total of monthly cash */
                              /* receipts in the */
                              /* Massachusetts store */

12. #include <iostream.h>

    const float PI = 3.14159;    // Ratio of circumference
                                 //   to diameter
    int main()
    {
        float circumference;     // The computed circumference
                                 // of the circle
        circumference = PI * 7.8;
        cout < The circumference of a circle;
        cout < of diameter 7.8 is  < endl;
        cout < circumference < endl;
        return 0;
    }
13. Get a fresh printout of the program, leave the computer, and study the program until you understand the cause of the problem. Then correct the algorithm and the program as necessary before you go back to the computer and make any changes in the program file.
Exam Preparation Exercises
1. Mark the following identifiers either valid or invalid.
Valid
Invalid
a. item#1
______
______
b. data
______
______
c. y
______
______

 
< previous page page_87 next page >