< previous page page_180 next page >

Page 180
9. Given the input data
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
11 12.35 ABC
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
what is the value of each variable after the following statements are executed? Assume that i is of type int, x is of type float, and chl is of type char.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. cin >> i >> x >> chl >> chl;
b. cin >> chl >> i >> x;
10. Define the following terms as they apply to interactive input/output.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. Input prompt
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. Echo printing
11. Correct the following program so that it reads a value from the file inData and writes it to the file outData.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
#include <iostream.h>

int main()
{
    int       n;
    ifstream inData;

    outData.open(results.dat);
    cin >> n;
    outData << n << endl;
    return 0;
}
12. Use your corrected version of the program in Exercise 11 to answer the following questions.
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
a. If the file inData initially contains the value 144, what does it contain after the program is executed?
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
b. If the file outData is initially empty, what are its contents after the program is executed?
13. List three characteristics of programs that are designed using a highly organized methodology such as top-down design or object-oriented design.
Programming Warm-Up Exercises
1. Your program has three char variables: ch1, ch2, and ch3. Given the input data
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
A B C\n
3e26ecb1b6ac508ae10a0e39d2fb98b2.gif
write the input statement(s) required to store the A into ch1, the B into ch2, and the C into ch3. Note that each pair of input characters is separated by two blanks.

 
< previous page page_180 next page >