CHAPTER 5
Which of the following is true?
A WHILE loop iterates on a True evaluation.
Which of the following is true regarding and if or an if else statement?
An if statement executes one block, whereas an if else statement lets the program decide which of two blocks is executed.
Which of the following statements is true?
Any FOR statement can be rewritten as a WHILE statement. Any WHILE statement can be rewritten as a FOR statement. - BOTH ARE TRUE
Which of these statements is true about FOR loops
The first part of a FOR statement can be left empty.
Which of the following is a posttest loop?
a DO-WHILE loop
In which type of loop might the loop body never execute?
a WHILE loop
When a loop is contained within another loop, the loops are ______.
a nested if
A trivial IF condition is one that ________________.
always has the same value
A FOR loop is ______.
an entry condition loop
A Do ... WHILE loop is ______.
an exit condition loop
A variable that determines whether a loop body will execute is the loop ____ variable.
control
Which of the following is a valid C++ loop declaration?
for (int i = 0; i 5; i++)
A FOR loop is commonly used ____.
in counting situations, because you can place all relevant information in one location
A loop control variable should almost always be used three times in these ways:
initialize, compare, alter
Regarding the execution of code under the if condition:
it always executes if the condition is true
It is important to remember when designing with a WHILE loop, ______.
it may not execute the body of the loop depending upon the test condition
In a DO .. WHILE loop, ___.
the boolean expression is always evaluated at least once
Comparing if-else and switch statements:
the if-else is more versatile than the switch
In an IF-ELSE statement, the else clause executes __________.
when the tested condition is false
A WHILE loop is commonly used _____.
when you don't know in advance precisely the number of times the loop will iterate