|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
|
5. int count;
float sum;
char letter; |
|
|
|
 |
|
|
|
|
b. 9 / 5 8. 1 |
|
|
|
|
|
|
|
|
9. cout < Programming and Problem Solving with C++ < endl; |
|
|
|
|
|
|
|
|
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. |
|
|
|
|
|