Deck 5: Looping

Full screen (f)
exit full mode
Question
What keyword(s) should you use to initiate a for-loop in C#?

A) while
B) do
C) repeat each
D) for
Use Space or
up arrow
down arrow
to flip the card.
Question
Unlike the while and for loops, the do loop is considered to be in what category of loops?

A) intest loops
B) pretest loops
C) posttest loops
D) fortest loops
Question
What type of loop allows you to 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
Loops that are controlled by reducing a variable are utilizing what type of loop control variable?

A) incrementing
B) comparing
C) decrementing
D) expanding
Question
A bug has resulted in your program executing an infinite loop.What key can be pressed in conjunction with the C or Break (Pause) key to escape the loop?

A) Esc
B) Ctrl
C) Shift
D) Alt
Question
Many loop control variable values rely on an added value through each loop.What type of loop control variable is this?

A) A comparing loop control variable.
B) A reducing loop control variable.
C) An expanding loop control variable.
D) An incrementing loop control variable.
Question
A Boolean expression is evaluated within every while loop to determine whether the loop body will execute.
Question
What type of 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
You cannot use a while loop for indefinite loops.
Question
Both the while loop and for loops are considered to be in what category of loops?

A) posttest loops
B) pretest loops
C) intest loops
D) for-test loops
Question
What is any single execution of a loop referred to as?

A) A lap of the loop.
B) An iteration of the loop.
C) A path through the loop.
D) A round in the loop.
Question
You can improve loop performance by using prefix incrementing.
Question
Statements in a for loop body cannot be blocked.
Question
What type of 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
A loop for which the number of iterations is predetermined is known as what type of loop?

A) indefinite
B) infinite
C) while
D) definite
Question
When loop structures are nested, the inner loop must be entirely contained within the outer loop; loops can never overlap.
Question
A loop that is controlled by user input rather than altered by arithmetic is known as what type of loop?

A) definite
B) indefinite
C) sentinel
D) infinite
Question
What type of 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
What are the block of statements that are executed in a loop considered to be part of?

A) a loop body
B) an iteration block
C) the loop header
D) the loop block
Question
When using nested loops, what loop is contained entirely within an outer loop?

A) posttest loop
B) pretest loop
C) inner loop
D) for loop
Question
Why do event-driven GUI programs sometimes require fewer coded loops than their counterpart console applications?

A) Some events are determined by the user's actions when the program is running.
B) GUI programs have better loop performance and can benefit more from loop fusion.
C) A GUI's properties removes the need for some loops.
D) A GUI program can utilize loop nesting, while a console program cannot.
Question
A value such as a 'Y' or 'N' that must be supplied in order to stop a loop is known as what type of value?

A) control value
B) sentinel value
C) stop value
D) switch value
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
You are writing a program that defines a variable within a loop, and then tries to use that variable outside the loop.However, the program does not run as intended.What is the issue?

A) The variable is being overwritten inside the loop.
B) The variable is declared with an incorrect type.
C) The variable is limited to the scope of the loop.
D) The variable name conflicts with a built in keyword.
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
When using a nested loop, what should always be thought of as the all-encompassing loop?

A) inner loop
B) outer loop
C) while loop
D) for loop
Question
After executing your GUI program, you realize that your code has created an infinite loop.How can you break free of the loop in your GUI program?

A) Use Ctrl + C
B) Use Ctrl + Break
C) Close the Frame that hosts the application
D) Close the IDE
Question
What are three common ways that the value of a loop control variable is changed during the loop's execution?
Question
What should an accumulator variable be set to before it is used to accumulate a total?

A) 1
B) false
C) true
D) 0
Question
Why is it important to initialize an accumulator variable?
Question
What technique can be used to combine two different loops into one?

A) pretesting loop
B) short-circuiting loop
C) loop accumulation
D) loop fusion
Question
The expressions in each part of an AND or OR expression are evaluated only as much as necessary to determine whether the entire expression is true or false.What type of evaluation is this?

A) while
B) stopwatch
C) short-circuit
D) loop
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 < a + b)
// 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
Briefly describe the structure of a for loop.
Question
What is a garbage value in the C# programming language?

A) It is an unknown, unassigned value.
B) It is a variable that is assigned a value that has no purpose.
C) It is a variable that is used as a placeholder.
D) It is a variable that holds output text after it is displayed.
Question
Write a short program that prints Hello on the console four times using a while 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
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
Totals that are summed one at a time in a loop are known as what type of totals?

A) decremented
B) incremented
C) derived
D) accumulated
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/40
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 5: Looping
1
What keyword(s) should you use to initiate a for-loop in C#?

A) while
B) do
C) repeat each
D) for
D
2
Unlike the while and for loops, the do loop is considered to be in what category of loops?

A) intest loops
B) pretest loops
C) posttest loops
D) fortest loops
C
3
What type of loop allows you to 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
A
4
Loops that are controlled by reducing a variable are utilizing what type of loop control variable?

A) incrementing
B) comparing
C) decrementing
D) expanding
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
5
A bug has resulted in your program executing an infinite loop.What key can be pressed in conjunction with the C or Break (Pause) key to escape the loop?

A) Esc
B) Ctrl
C) Shift
D) Alt
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
6
Many loop control variable values rely on an added value through each loop.What type of loop control variable is this?

A) A comparing loop control variable.
B) A reducing loop control variable.
C) An expanding loop control variable.
D) An incrementing loop control variable.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
7
A Boolean expression is evaluated within every while loop to determine whether the loop body will execute.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
8
What type of 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 40 flashcards in this deck.
Unlock Deck
k this deck
9
You cannot use a while loop for indefinite loops.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
10
Both the while loop and for loops are considered to be in what category of loops?

A) posttest loops
B) pretest loops
C) intest loops
D) for-test loops
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
11
What is any single execution of a loop referred to as?

A) A lap of the loop.
B) An iteration of the loop.
C) A path through the loop.
D) A round in the loop.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
12
You can improve loop performance by using prefix incrementing.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
13
Statements in a for loop body cannot be blocked.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
14
What type of 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
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
15
A loop for which the number of iterations is predetermined is known as what type of loop?

A) indefinite
B) infinite
C) while
D) definite
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
16
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 40 flashcards in this deck.
Unlock Deck
k this deck
17
A loop that is controlled by user input rather than altered by arithmetic is known as what type of loop?

A) definite
B) indefinite
C) sentinel
D) infinite
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
18
What type of 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 40 flashcards in this deck.
Unlock Deck
k this deck
19
What are the block of statements that are executed in a loop considered to be part of?

A) a loop body
B) an iteration block
C) the loop header
D) the loop block
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
20
When using nested loops, what loop is contained entirely within an outer loop?

A) posttest loop
B) pretest loop
C) inner loop
D) for loop
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
21
Why do event-driven GUI programs sometimes require fewer coded loops than their counterpart console applications?

A) Some events are determined by the user's actions when the program is running.
B) GUI programs have better loop performance and can benefit more from loop fusion.
C) A GUI's properties removes the need for some loops.
D) A GUI program can utilize loop nesting, while a console program cannot.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
22
A value such as a 'Y' or 'N' that must be supplied in order to stop a loop is known as what type of value?

A) control value
B) sentinel value
C) stop value
D) switch value
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
23
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 40 flashcards in this deck.
Unlock Deck
k this deck
24
You are writing a program that defines a variable within a loop, and then tries to use that variable outside the loop.However, the program does not run as intended.What is the issue?

A) The variable is being overwritten inside the loop.
B) The variable is declared with an incorrect type.
C) The variable is limited to the scope of the loop.
D) The variable name conflicts with a built in keyword.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
25
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 40 flashcards in this deck.
Unlock Deck
k this deck
26
When using a nested loop, what should always be thought of as the all-encompassing loop?

A) inner loop
B) outer loop
C) while loop
D) for loop
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
27
After executing your GUI program, you realize that your code has created an infinite loop.How can you break free of the loop in your GUI program?

A) Use Ctrl + C
B) Use Ctrl + Break
C) Close the Frame that hosts the application
D) Close the IDE
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
28
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 40 flashcards in this deck.
Unlock Deck
k this deck
29
What should an accumulator variable 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 40 flashcards in this deck.
Unlock Deck
k this deck
30
Why is it important to initialize an accumulator variable?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
31
What technique can be used to combine two different loops into one?

A) pretesting loop
B) short-circuiting loop
C) loop accumulation
D) loop fusion
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
32
The expressions in each part of an AND or OR expression are evaluated only as much as necessary to determine whether the entire expression is true or false.What type of evaluation is this?

A) while
B) stopwatch
C) short-circuit
D) loop
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
33
When writing a while loop, how can you ensure that it will end correctly?
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
34
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 < a + b)
// 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 40 flashcards in this deck.
Unlock Deck
k this deck
35
Briefly describe the structure of a for loop.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
36
What is a garbage value in the C# programming language?

A) It is an unknown, unassigned value.
B) It is a variable that is assigned a value that has no purpose.
C) It is a variable that is used as a placeholder.
D) It is a variable that holds output text after it is displayed.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
37
Write a short program that prints Hello on the console four times using a while loop.
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
38
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 40 flashcards in this deck.
Unlock Deck
k this deck
39
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 40 flashcards in this deck.
Unlock Deck
k this deck
40
Totals that are summed one at a time in a loop are known as what type of totals?

A) decremented
B) incremented
C) derived
D) accumulated
Unlock Deck
Unlock for access to all 40 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 40 flashcards in this deck.