-
A structure that allows repeated execution of a block of statements is a(n) ______.
D. loop
-
The body of a while loop can consist of _______.
A. a single statement
B. a block of statements within curly
braces
C. either a or b
D. neither a nor b
C. either a or b
-
A loop that never ends is called an _________ loop.
C. infinite
-
Which of the following is not required of a loop control variable in a correctly working loop?
D. It is reset to its initial value before the loop ends
-
A while loop with an empty body contains no _________.
A. statements
-
A loop for which you do not know the number of iterations when you write it is a(n) ________.
C. indefinite loop
-
What is the major advantage of using a for loop instead of a while loop?
D. The loop control variable is initialized, tested, and altered all in one place.
-
A for loop statement must contain _______.
C. two semicolons
-
In a for statement, the section before the first semicolon executes ________.
B. once
-
The three sections of the for loop are most commonly used for _______ the loop control variable.
D. initializing, testing, and incrementing
-
Which loop is most convenient to use if the loop body must always execute at least once?
C. a do loop
-
The loop control variable is checked at the bottom of which kind of loop?
C. a do loop
-
A for loop is an example of a(n) _______ loop.
B. pretest
-
A while loop is an example of a(n) ______ loop.
A. pretest
-
When a loop is placed within another loop, the loops are said to be ________.
B. nested
-
What does the following code segment display?
a = 1;
while (a < 5);
{
Write("{0} ", a);
++a;
}
A. 1234
B. 1
C. 4
D. nothing
D. nothing
-
What is the output of the following code segment?
s=1;
while (s < 4)
++s;
Write("{0} ", s);
C. 4
-
What is the output of the following code segment?
j = 5;
while (j > 0)
{
Write("{0} ", j);
j--;
}
C. 54321
-
What does the following code segment display?
for (f = 0; f < 3; ++f);
Write("{0} ", f);
C. 3
-
What does the following code segment display?
for (t = 0; t < 3; ++t)
Write("{0} ", t);
D. 012
|
|