True/False
Indicate whether the sentence or statement is true
or false.
|
|
1.
|
Reading input from a keyboard is considered interactive Input/Output because the user
is communicating directly with the computer.
|
|
2.
|
Assuming no input errors, an execution of the >> operator leaves the reading
marker at the character immediately following the last data item read.
|
|
3.
|
Using
the >> operator, a floating point data value may be read into an
int
variable.
|
|
4.
|
The
input statement
cin >> someInt;
could also be written as
someInt << cin;
|
|
5.
|
If
the reading marker is in the middle of an input line of 25 characters, execution of the
statement
cin.ignore(5000, '\n');
leaves the reading marker at the character following the next newline
character.
|
|
6.
|
If a
C++ program attempts to input invalid data, the computer system immediately terminates the program
and displays an error message.
|
|
7.
|
The
>> operator skips leading whitespace characters when looking for the next data value in the
input stream.
|
|
8.
|
In
the statement
cin >> XXXXX;
the XXXXX must be a variable name, not a constant or arbitrary
expression.
|
|
9.
|
The
single statement
cin >> alpha >> beta;
will not cause an error when used in place of the two
statements
cin >> alpha;
cin >>
beta;
|
|
10.
|
When
working at the keyboard, the user generates a newline character by pressing the Enter or Return
key.
|
Multiple Choice
Identify the
letter of the choice that best completes the statement or answers the question.
|
|
11.
|
Which of the following is NOT a good reason for using batch Input/Output?
a. | A large amount
of input data is expected. | c. | The program only
requires one or two pieces of date to be input. | b. | The input data
can be prepared ahead of time. | d. | The output from
one program can be used as the input to another. | | | | |
|
|
12.
|
Which
of the following statements sends a newline character to the standard output
device?
a. | cout <<
endl; | c. | cout <<
\n; | b. | cout <<
'\n'; | d. | both answers a
and b send a newline character to the standard output device. | | | | |
|
|
13.
|
A
value can be stored into a variable by execution of: a. | an input
statement | c. | an assignment
statement | b. | an output statement | d. | both answers a and c | | | | |
|
|
14.
|
Which
of the following is considered interactive I/O (Input/Output)?
a. | Typing employee
records according to prompts from a program and printing the names of salaried
employees | c. | Reading a file
of numbers and printing their average | b. | Displaying sales records from a file onto the computer
monitor | d. | None of
these | | | | |
|
|
15.
|
Given
the three lines of input data
111 222
333
444 555 666
777 888 999
what value is read into gamma by the following code? (All variables
are of type int.)
cin >> alpha;
cin.ignore(500,
'\n');
cin >> beta >> gamma;
a. | 333 | d. | 777 | b. | 444 | e. | none of these | c. | 555 | | | | |
|
|
16.
|
Given
the line of input data
123.456 A
789
what value is read into inputChar by the following
code? (alpha and beta are of type int, and inputChar is of type char.)
cin >> alpha >> inputChar >>
beta;
a. | ' '
(blank)
| d. | '4'
| b. | 'A' | e. | none of these | c. | '.'
(period) | | | | |
|
|
17.
|
Which
of the following is a valid input statement?
a. | cin >> studentAge; | d. | studentAge << cin; | b. | cin <<
studentAge; | e. | both answers a
and c | c. | studentAge >> cin; | | | | |
|
|
18.
|
Given
the constant declaration
const int FACTOR
= 95;
which of the following is not a valid use of
FACTOR?
a. | cout <<
FACTOR * 3; | d. | both answers a
and c | b. | FACTOR = 24; | e. | both answers b and c | c. | cin >>
FACTOR; | | | | |
|
|
19.
|
Which
of the following statements about C++ stream input is true?
a. | When an integer
data value is read into a float variable, the value is first converted into floating point
form. | d. | Input of a
floating point data value stops when a decimal point is encountered. | b. | When an integer
data value is read into a float variable, the float variable becomes an int
variable. | e. | both answers c
and d | c. | It is an error to read an integer data value into a float
variable. | | | | |
|
|
20.
|
Given
the two lines of input data
A
B
CDE
what value is read into ch3 by the following code?
(All variables are of type char.)
cin >> ch1
>> ch2 >> ch3;
a. | 'B' | d. | 'D'
| b. | '\n' | e. | none of
these | c. | 'C' | | | | |
|