|
|
|
|
|
|
|
2. Change your answer to Exercise 1 so that the A is stored into ch1 and the next two blanks are stored into ch2 and ch3. |
|
|
|
|
|
|
|
|
3. Write a single input statement that reads the input lines |
|
|
|
 |
|
|
|
|
10.25 7.625\n
8.5\n
1.0\n |
|
|
|
 |
|
|
|
|
and stores the four values into the float variables length1, height1, length2, and height2. |
|
|
|
|
|
|
|
|
4. Write a series of statements that input the first letter of each of the following names into the char variables chr1, chr2, and chr3. |
|
|
|
 |
|
|
|
|
Peter\n
Kitty\n
Kathy\n |
|
|
|
|
|
|
|
|
5. Write a set of variable declarations and a series of input statements to read the following lines of data into variables of the appropriate type. You can make up the variable names. Notice that the values are separated from one another by a single blank and that there are no blanks to the left of the first character on each line. |
|
|
|
 |
|
|
|
|
A 100 2.78 g 14\n
207.98 w q 23.4 92\n
R 42 L 27 R 63\n |
|
|
|
|
|
|
|
|
6. Write a program segment that reads nine integer values from a file and writes them to the screen, three numbers per output line. The file is organized one value to a line. |
|
|
|
|
|
|
|
|
7. Write a code segment for an interactive program to input values for a person's age, height, and weight, and the initials of their first and last names. The numeric values are all integers. Assume that the person using the program is a novice user. How would you rewrite the code for an experienced user? |
|
|
|
|
|
|
|
|
8. Fill in the blanks in the following program, which should read four values from the file dataIn and output them to the file resultsOut. |
|
|
|
 |
|
|
|
|
#include____________
#include____________
int main()
{
int val1;
int val2;
int val3;
int val4;
_______ dataIn;
ofstream __________;
|
|
|
|
|
|