Chapter 4 Program Input and the Software Design
Exam Preparation Exercises
The main advantage of having a program input its data rather than writing all of the values as
constants is that the program does not have to be changed when a new set of data needs to be run
through it. If all values were declared as const data, those values would have to
be modified and the program recompiled every time it was run. When
the program inputs the values, it can run on many different data sets
without modification of the source code.
The >> operator skips leading whitespace characters (if any), whereas
the get function does not. The get function inputs the next character
waiting in the input stream, even if it is a whitespace character.
True (with the understanding that an integer input value is converted into floating−point form before
it is stored into the float variable).
a contains 14, b contains 19, c contains 67, d contains 73
A newline character is entered from the keyboard by pressing the Return or Enter key.
A program can generate a newline character in its output either by using the endl
manipulator or by explicitly outputting the single character
denoted by the symbols \n.
i contains 11, x contains 12.35, ch1 contains ’A’
i contains 1, x contains 12.35, ch1 contains ’1’
String address contains the string “40”.
The reading marker is positioned at the blank character before the T in Tall.
String address contains the string “40 Tall Pine Drive”.
The reading marker is positioned at the character S of Sudbury (because the getline
function consumes the newline character).
12. An input prompt is a message printed out directly before an input statement, telling the user what
kind of input is expected by the input statement. Echo printing refers to printing out the values of
variables directly after they are read, in order to verify that the variables contain the proper...