TRUE OR FALSE Flashcards
(46 cards)
The extraction operator»_space; skips all leading whitespace characters when searching for the next data in the input stream
TRUE
In the statement cin»_space; x;, x must be a variable.
TRUE
The statement cin»_space; x»_space; y; requires the input values for x and y to appear on the same line.
FALSE
The statement cin»_space; num; is equivalent to the statement num»_space; cin;
FALSE
You generate the newline character by pressing the Enter (return) key
on the keyboard.
FALSE
The function ignore is used to skip certain input in a line.
TRUE
The result of a logical expression cannot be assigned to an int variable
FALSE
In a one-way selection, if a semicolon is placed after the expression in
an if statement, the expression in the if statement is always true.
TRUE
Every if statement must have a corresponding else.
FALSE
The expression in the if statement:
if (score = 30)
grade = ‘A’;
always evaluates to true.
TRUE
The expression:
(ch >= ‘A’ && ch <= ‘Z’)
evaluates to false if either ch < ‘A’ or ch >= ‘Z’.
TRUE
Suppose the input is 5. The output of the code:
cin»_space; num;
if (num > 5)
cout «_space;num;
num = 0;
else
cout «_space;“Num is zero” «_space;endl;
is: Num is zero
TRUE
The expression in a switch statement should evaluate to a value of the
simple data type.
TRUE
The expression !(x > 0) is true only if x is a negative number.
TRUE
In C++, both ! and != are logical operators.
FALSE
The order in which statements execute in a program is called the flow of control.
TRUE
In a counter-controlled while loop, it is not necessary to initialize the
loop control variable.
FALSE
It is possible that the body of a while loop may not execute at all
FALSE
In an infinite while loop, the while expression (the decision maker) is
initially false, but after the first iteration it is always true
FALSE
The while loop:
j = 0;
while (j <= 10)
j++;
terminates if j > 10
TRUE
A sentinel-controlled while loop is an event-controlled while loop
whose termination depends on a special value.
TRUE
A loop is a control structure that causes certain statements to execute
over and over.
TRUE
To read data from a file of an unspecified length, an EOF-controlled
loop is a good choice.
TRUE
When a while loop terminates, the control first goes back to the
statement just before the while statement, and then the control goes
to the statement immediately following the while loop.
FALSE