1. Declare a constant ROUND_FACTOR (defined to be equal to the desired rounding factor, such as 100.0 for hundredths) and replace every occurrence of 10.0 with ROUND_FACTOR.
Chapter 4
Exam Preparation Exercises
2. a. int1 contains 17, int2 contains 13, and int3 contains 7.
b. The leftover values remain waiting in the input stream. These values will be read by subsequent input statements (or they will be ignored if no more input statements are executed).
6. True
8. 123 147
11. Errors in the program are as follows:
The declaration of outData is missing:
ofstream outData;
The opening of the input file is missing:
inData.open(myfile.dat);
The statement
cin >> n;
does not read from the input file. Change cin to inData.
12. With the corrected version of the program in Exercise 11, file inData will still contain the 144 after the program is executed. File outData will contain 144, followed by a newline character.