Deck 5: Looping

Full screen (f)
exit full mode
Question
You begin a for statement with the keyword ____ followed by a set of parentheses.

A) while
B) do
C) repeat each
D) for
Use Space or
up arrow
down arrow
to flip the card.
Question
A loop for which the number of iterations is predetermined is called a(n) ____ loop.

A) indefinite
B) infinite
C) counted
D) definite
Question
The ____ loop checks a Boolean expression at the "top" of the loop before the body has a chance to execute.

A) do
B) repeat
C) switch
D) while
Question
Many loop control variable values are altered by ____ (or adding to) them.

A) comparing
B) reducing
C) expanding
D) incrementing
Question
When loop structures are nested, the inner loop must be entirely contained within the outer loop; loops can never overlap.
Question
A Boolean expression is evaluated within every while loop to determine whether the loop body will execute.
Question
The do  loop is a(n) ____ loop.

A) intest
B) pretest
C) posttest
D) fortest
Question
You can improve loop performance by using prefix incrementing.
Question
Often, the value of a loop control variable is not altered by arithmetic, but instead is altered by user input. This type of loop is a(n) ____ loop.

A) definite
B) indefinite
C) sentinel
D) infinite
Question
The ____ loop checks a Boolean expression at the "bottom" of the loop after each repetition has occurred.

A) do
B) for
C) switch
D) while
Question
Statements in a for loop body cannot be blocked.
Question
One execution of any loop is called a(n) ____.

A) lap
B) iteration
C) path
D) round
Question
With a ____ loop, you can indicate the starting value for the loop control variable, the test condition that controls loop entry, and the expression that alters the loop control variable, all in one convenient place.

A) for
B) do
C) repeat
D) while
Question
When loops are nested, each pair contains a(n) ____ loop and an outer loop.

A) posttest
B) pretest
C) inner
D) for
Question
You cannot use a while loop for indefinite loops.
Question
Some loops are controlled by ____ (or reducing) a variable and testing whether the value remains greater than some benchmark value.

A) incrementing
B) comparing
C) decrementing
D) expanding
Question
A while loop is a(n) ____ loop.

A) posttest
B) pretest
C) intest
D) fortest
Question
If you ever find yourself in the midst of executing an infinite loop, you can break out by holding down the ____ key and pressing the C key or the Break (Pause) key.

A) Esc
B) Ctrl
C) Shift
D) Alt
Question
The block of statements executed in a loop is known as the ____.

A) loop body
B) iteration block
C) loop header
D) loop block
Question
A(n) ____ loop is one in which the loop control variable is tested after the loop body executes.

A) posttest
B) intest
C) fortest
D) pretest
Question
Why is it important to initialize an accumulator variable?
Question
Often, totals are ____; that is, summed one at a time in a loop.

A) decremented
B) incremented
C) derived
D) accumulated
Question
The expressions in each part of an AND or OR expression use ____ evaluation; that is, they are evaluated only as much as necessary to determine whether the entire expression is true or false .

A) while
B) stopwatch
C) short-circuit
D) loop
Question
Loop ____ is the technique of combining two loops into one.

A) pretesting
B) short-circuiting
C) accumulation
D) fusion
Question
You can use a(n) ____________________ loop to execute a body of statements continuously as long as some condition continues to be true .
Question
Event-driven GUI programs sometimes require fewer coded loops than their counterpart console applications because some events are determined by the ____ when the program is running.

A) user's actions
B) loop performance
C) GUI's properties
D) loop nesting
Question
A value that a user must supply to stop a loop (for example, 'Y' or 'N' ) is called a(n) ____________________ value.
Question
Statements in a while loop or for loop body can be blocked. Write a for loop that displays "Hello" and "Goodbye" four times each using a blocked loop body.
Question
When a variable is declared inside a loop, it can be referenced only for the duration of the loop body. Once the loop finishes execution, the variable is out of ____________________, which means it is not usable because it has ceased to exist.
Question
When you use a loop within a loop, you should always think of the ____ loop as the all-encompassing loop.

A) inner
B) outer
C) while
D) for
Question
A(n) ____________________ is a structure that allows repeated execution of a block of statements.
Question
When writing a while loop, how can you ensure that it will end correctly?
Question
Suppose a loop should execute while x is less than the sum of two integers, a and b . The loop could be written as:
while (x
// loop body
Although this code fragment will run, it is not particularly efficient. In what way is it inefficient, and how could you improve the loop's performance?
Question
Write two code segments that print the integers 1 through 10. One segment should use a while loop and the other should use a for loop.
Question
Because you need definite loops so frequently when you write programs, C# provides a shorthand way to create such a loop. This shorthand structure is called a(n) ____________________ loop.
Question
What tasks can be performed in the three sections of a for loop in addition to initializing a single variable, testing the variable, and incrementing it?
Question
Briefly describe the structure of a for loop.
Question
An accumulator variable must be set to ____ before it is used to accumulate a total.

A) 1
B) false
C) true
D) 0
Question
Write a short program that prints "Hello" on the console four times using a while loop.
Question
What are three common ways that the value of a loop control variable is changed during the loop's execution?
Question
When a loop might execute many times, it becomes increasingly important to consider the number of evaluations that take place. How can considering the order of evaluation of short-circuit operators affect the performance of a loop?
Question
Match between columns
A loop that never ends
infinite loop
A loop that never ends
for loop
A loop that never ends
step value
A loop that never ends
counted loop
A loop that never ends
outer loop
A loop that never ends
do loop
A loop that never ends
garbage
A loop that never ends
loop control variable
A loop that never ends
empty body
The value of an uninitialized variable
infinite loop
The value of an uninitialized variable
for loop
The value of an uninitialized variable
step value
The value of an uninitialized variable
counted loop
The value of an uninitialized variable
outer loop
The value of an uninitialized variable
do loop
The value of an uninitialized variable
garbage
The value of an uninitialized variable
loop control variable
The value of an uninitialized variable
empty body
Another name for a definite loop
infinite loop
Another name for a definite loop
for loop
Another name for a definite loop
step value
Another name for a definite loop
counted loop
Another name for a definite loop
outer loop
Another name for a definite loop
do loop
Another name for a definite loop
garbage
Another name for a definite loop
loop control variable
Another name for a definite loop
empty body
The amount by which a loop control variable changes on each cycle
infinite loop
The amount by which a loop control variable changes on each cycle
for loop
The amount by which a loop control variable changes on each cycle
step value
The amount by which a loop control variable changes on each cycle
counted loop
The amount by which a loop control variable changes on each cycle
outer loop
The amount by which a loop control variable changes on each cycle
do loop
The amount by which a loop control variable changes on each cycle
garbage
The amount by which a loop control variable changes on each cycle
loop control variable
The amount by which a loop control variable changes on each cycle
empty body
Checks at the "bottom" of the loop after the first iteration
infinite loop
Checks at the "bottom" of the loop after the first iteration
for loop
Checks at the "bottom" of the loop after the first iteration
step value
Checks at the "bottom" of the loop after the first iteration
counted loop
Checks at the "bottom" of the loop after the first iteration
outer loop
Checks at the "bottom" of the loop after the first iteration
do loop
Checks at the "bottom" of the loop after the first iteration
garbage
Checks at the "bottom" of the loop after the first iteration
loop control variable
Checks at the "bottom" of the loop after the first iteration
empty body
Contains an inner loop when loops are nested
infinite loop
Contains an inner loop when loops are nested
for loop
Contains an inner loop when loops are nested
step value
Contains an inner loop when loops are nested
counted loop
Contains an inner loop when loops are nested
outer loop
Contains an inner loop when loops are nested
do loop
Contains an inner loop when loops are nested
garbage
Contains an inner loop when loops are nested
loop control variable
Contains an inner loop when loops are nested
empty body
A variable that controls the execution of a while loop
infinite loop
A variable that controls the execution of a while loop
for loop
A variable that controls the execution of a while loop
step value
A variable that controls the execution of a while loop
counted loop
A variable that controls the execution of a while loop
outer loop
A variable that controls the execution of a while loop
do loop
A variable that controls the execution of a while loop
garbage
A variable that controls the execution of a while loop
loop control variable
A variable that controls the execution of a while loop
empty body
A shorthand structure for programming a definite loop
infinite loop
A shorthand structure for programming a definite loop
for loop
A shorthand structure for programming a definite loop
step value
A shorthand structure for programming a definite loop
counted loop
A shorthand structure for programming a definite loop
outer loop
A shorthand structure for programming a definite loop
do loop
A shorthand structure for programming a definite loop
garbage
A shorthand structure for programming a definite loop
loop control variable
A shorthand structure for programming a definite loop
empty body
A loop body with no statements in it
infinite loop
A loop body with no statements in it
for loop
A loop body with no statements in it
step value
A loop body with no statements in it
counted loop
A loop body with no statements in it
outer loop
A loop body with no statements in it
do loop
A loop body with no statements in it
garbage
A loop body with no statements in it
loop control variable
A loop body with no statements in it
empty body
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/42
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: Looping
1
You begin a for statement with the keyword ____ followed by a set of parentheses.

A) while
B) do
C) repeat each
D) for
D
2
A loop for which the number of iterations is predetermined is called a(n) ____ loop.

A) indefinite
B) infinite
C) counted
D) definite
D
3
The ____ loop checks a Boolean expression at the "top" of the loop before the body has a chance to execute.

A) do
B) repeat
C) switch
D) while
D
4
Many loop control variable values are altered by ____ (or adding to) them.

A) comparing
B) reducing
C) expanding
D) incrementing
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
5
When loop structures are nested, the inner loop must be entirely contained within the outer loop; loops can never overlap.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
6
A Boolean expression is evaluated within every while loop to determine whether the loop body will execute.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
7
The do  loop is a(n) ____ loop.

A) intest
B) pretest
C) posttest
D) fortest
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
8
You can improve loop performance by using prefix incrementing.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
9
Often, the value of a loop control variable is not altered by arithmetic, but instead is altered by user input. This type of loop is a(n) ____ loop.

A) definite
B) indefinite
C) sentinel
D) infinite
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
10
The ____ loop checks a Boolean expression at the "bottom" of the loop after each repetition has occurred.

A) do
B) for
C) switch
D) while
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
11
Statements in a for loop body cannot be blocked.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
12
One execution of any loop is called a(n) ____.

A) lap
B) iteration
C) path
D) round
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
13
With a ____ loop, you can indicate the starting value for the loop control variable, the test condition that controls loop entry, and the expression that alters the loop control variable, all in one convenient place.

A) for
B) do
C) repeat
D) while
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
14
When loops are nested, each pair contains a(n) ____ loop and an outer loop.

A) posttest
B) pretest
C) inner
D) for
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
15
You cannot use a while loop for indefinite loops.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
16
Some loops are controlled by ____ (or reducing) a variable and testing whether the value remains greater than some benchmark value.

A) incrementing
B) comparing
C) decrementing
D) expanding
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
17
A while loop is a(n) ____ loop.

A) posttest
B) pretest
C) intest
D) fortest
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
18
If you ever find yourself in the midst of executing an infinite loop, you can break out by holding down the ____ key and pressing the C key or the Break (Pause) key.

A) Esc
B) Ctrl
C) Shift
D) Alt
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
19
The block of statements executed in a loop is known as the ____.

A) loop body
B) iteration block
C) loop header
D) loop block
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
20
A(n) ____ loop is one in which the loop control variable is tested after the loop body executes.

A) posttest
B) intest
C) fortest
D) pretest
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
21
Why is it important to initialize an accumulator variable?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
22
Often, totals are ____; that is, summed one at a time in a loop.

A) decremented
B) incremented
C) derived
D) accumulated
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
23
The expressions in each part of an AND or OR expression use ____ evaluation; that is, they are evaluated only as much as necessary to determine whether the entire expression is true or false .

A) while
B) stopwatch
C) short-circuit
D) loop
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
24
Loop ____ is the technique of combining two loops into one.

A) pretesting
B) short-circuiting
C) accumulation
D) fusion
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
25
You can use a(n) ____________________ loop to execute a body of statements continuously as long as some condition continues to be true .
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
26
Event-driven GUI programs sometimes require fewer coded loops than their counterpart console applications because some events are determined by the ____ when the program is running.

A) user's actions
B) loop performance
C) GUI's properties
D) loop nesting
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
27
A value that a user must supply to stop a loop (for example, 'Y' or 'N' ) is called a(n) ____________________ value.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
28
Statements in a while loop or for loop body can be blocked. Write a for loop that displays "Hello" and "Goodbye" four times each using a blocked loop body.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
29
When a variable is declared inside a loop, it can be referenced only for the duration of the loop body. Once the loop finishes execution, the variable is out of ____________________, which means it is not usable because it has ceased to exist.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
30
When you use a loop within a loop, you should always think of the ____ loop as the all-encompassing loop.

A) inner
B) outer
C) while
D) for
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
31
A(n) ____________________ is a structure that allows repeated execution of a block of statements.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
32
When writing a while loop, how can you ensure that it will end correctly?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
33
Suppose a loop should execute while x is less than the sum of two integers, a and b . The loop could be written as:
while (x
// loop body
Although this code fragment will run, it is not particularly efficient. In what way is it inefficient, and how could you improve the loop's performance?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
34
Write two code segments that print the integers 1 through 10. One segment should use a while loop and the other should use a for loop.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
35
Because you need definite loops so frequently when you write programs, C# provides a shorthand way to create such a loop. This shorthand structure is called a(n) ____________________ loop.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
36
What tasks can be performed in the three sections of a for loop in addition to initializing a single variable, testing the variable, and incrementing it?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
37
Briefly describe the structure of a for loop.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
38
An accumulator variable must be set to ____ before it is used to accumulate a total.

A) 1
B) false
C) true
D) 0
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
39
Write a short program that prints "Hello" on the console four times using a while loop.
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
40
What are three common ways that the value of a loop control variable is changed during the loop's execution?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
41
When a loop might execute many times, it becomes increasingly important to consider the number of evaluations that take place. How can considering the order of evaluation of short-circuit operators affect the performance of a loop?
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
42
Match between columns
A loop that never ends
infinite loop
A loop that never ends
for loop
A loop that never ends
step value
A loop that never ends
counted loop
A loop that never ends
outer loop
A loop that never ends
do loop
A loop that never ends
garbage
A loop that never ends
loop control variable
A loop that never ends
empty body
The value of an uninitialized variable
infinite loop
The value of an uninitialized variable
for loop
The value of an uninitialized variable
step value
The value of an uninitialized variable
counted loop
The value of an uninitialized variable
outer loop
The value of an uninitialized variable
do loop
The value of an uninitialized variable
garbage
The value of an uninitialized variable
loop control variable
The value of an uninitialized variable
empty body
Another name for a definite loop
infinite loop
Another name for a definite loop
for loop
Another name for a definite loop
step value
Another name for a definite loop
counted loop
Another name for a definite loop
outer loop
Another name for a definite loop
do loop
Another name for a definite loop
garbage
Another name for a definite loop
loop control variable
Another name for a definite loop
empty body
The amount by which a loop control variable changes on each cycle
infinite loop
The amount by which a loop control variable changes on each cycle
for loop
The amount by which a loop control variable changes on each cycle
step value
The amount by which a loop control variable changes on each cycle
counted loop
The amount by which a loop control variable changes on each cycle
outer loop
The amount by which a loop control variable changes on each cycle
do loop
The amount by which a loop control variable changes on each cycle
garbage
The amount by which a loop control variable changes on each cycle
loop control variable
The amount by which a loop control variable changes on each cycle
empty body
Checks at the "bottom" of the loop after the first iteration
infinite loop
Checks at the "bottom" of the loop after the first iteration
for loop
Checks at the "bottom" of the loop after the first iteration
step value
Checks at the "bottom" of the loop after the first iteration
counted loop
Checks at the "bottom" of the loop after the first iteration
outer loop
Checks at the "bottom" of the loop after the first iteration
do loop
Checks at the "bottom" of the loop after the first iteration
garbage
Checks at the "bottom" of the loop after the first iteration
loop control variable
Checks at the "bottom" of the loop after the first iteration
empty body
Contains an inner loop when loops are nested
infinite loop
Contains an inner loop when loops are nested
for loop
Contains an inner loop when loops are nested
step value
Contains an inner loop when loops are nested
counted loop
Contains an inner loop when loops are nested
outer loop
Contains an inner loop when loops are nested
do loop
Contains an inner loop when loops are nested
garbage
Contains an inner loop when loops are nested
loop control variable
Contains an inner loop when loops are nested
empty body
A variable that controls the execution of a while loop
infinite loop
A variable that controls the execution of a while loop
for loop
A variable that controls the execution of a while loop
step value
A variable that controls the execution of a while loop
counted loop
A variable that controls the execution of a while loop
outer loop
A variable that controls the execution of a while loop
do loop
A variable that controls the execution of a while loop
garbage
A variable that controls the execution of a while loop
loop control variable
A variable that controls the execution of a while loop
empty body
A shorthand structure for programming a definite loop
infinite loop
A shorthand structure for programming a definite loop
for loop
A shorthand structure for programming a definite loop
step value
A shorthand structure for programming a definite loop
counted loop
A shorthand structure for programming a definite loop
outer loop
A shorthand structure for programming a definite loop
do loop
A shorthand structure for programming a definite loop
garbage
A shorthand structure for programming a definite loop
loop control variable
A shorthand structure for programming a definite loop
empty body
A loop body with no statements in it
infinite loop
A loop body with no statements in it
for loop
A loop body with no statements in it
step value
A loop body with no statements in it
counted loop
A loop body with no statements in it
outer loop
A loop body with no statements in it
do loop
A loop body with no statements in it
garbage
A loop body with no statements in it
loop control variable
A loop body with no statements in it
empty body
Unlock Deck
Unlock for access to all 42 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 42 flashcards in this deck.