Deck 6: The Repetition Structure

Full screen (f)
exit full mode
Question
After the statements in a loop are performed, the condition is evaluated again; depending on the evaluation's outcome, the statements might be performed again.
Use Space or
up arrow
down arrow
to flip the card.
Question
Loops are commonly used to perform a task a specified number of times.
Question
Looping allows you to use one set of instructions to process multiple sets of data.
Question
A counter is numeric and often named value.
Question
The most common repetition structure is the For loop.
Question
On a flowchart, if you have a condition leading to statements on the true branch (or on both the true and false branches), but the flowline does not go back to the condition, it is a While loop.
Question
On a flowchart, if you have a condition leading to statements on the true branch, and the flowline goes back to the condition, it is an If (or If/Else) statement.
Question
With a determinate loop, you do not know the number of iterations ahead of time.
Question
An infinite loop is one that never ends.
Question
Continue is a reserved keyword in many languages, so it cannot be used as a variable name.
Question
The body of a pretest loop is always executed at least once.
Question
The Do While loop has only one entrance and one exit.
Question
In a While loop, the condition is at the beginning, guarding the entry point to the loop.
Question
In a JavaScript While loop, there is no semicolon after the condition.
Question
Loops have three components: initialization, condition testing, and validation.
Question
In a While loop, the loop variable can be initialized at any place in the program before the condition.
Question
In the Do While loop, the statement initializing the loop variable is usually the same statement that alters it.
Question
The decrement operator is ==.
Question
The Break statement is the only way to prevent the rest of the code from being performed.
Question
The Break statement cannot be used in a While or a Do While loop.
Question
The Break statement causes program control to skip immediately to the first statement after the end of the loop.
Question
When a Continue statement is used in a While or Do While loop, program control goes immediately to the beginning of the loop and starts a new iteration.
Question
In order to use a static variable or call a static method, you must create a separate object from the class.
Question
To call a static method in pseudocode, you use the keyword Call, the class name, a period (called a dot), the method name, and any arguments in parentheses.
Question
In JavaScript, you do not have to declare instance variables separately in the <head> section of the HTML file. They are declared automatically when the constructor method is called.
Question
The ____ is a section of programming instructions performed, perhaps repeatedly (and as many times as needed), as the result of a condition.

A) repetition structure
B) accumulator
C) increment operator
D) sentinel value
Question
Each performance (or execution) of the statements in a loop is called a(n) ____ of the loop.

A) iteration
B) accumulation
C) alteration
D) initialization
Question
A(n) ____ is a loop that never stops.

A) closed loop
B) infinite loop
C) enclosed loop
D) nested loop
Question
Adding to the value of a variable is known as ____ the variable.

A) evaluating
B) nesting
C) incrementing
D) decrementing
Question
The loop for displaying "Beetlejuice" three times is ____.

A) Declare Numeric index = 1
While index < 3
Display "Beetlejuice"
Index = index + 1
End While

B) Declare Numeric index = 0
While index == 3
Display "Beetlejuice"
Index = index + 1
End While

C) Declare Numeric index = 0
While index <= 3
Display "Beetlejuice"
Index = index + 1
End While

D) Declare Numeric index = 0
While index < 3
Display "Beetlejuice"
Index = index + 1
End While
Question
When a condition is evaluated before any statements are performed, the While loop is considered a(n) ____.

A) nested loop
B) pretest loop
C) posttest loop
D) infinite loop
Question
The JavaScript code for displaying "Beetlejuice" three times is ____.

A) var index = 0;
While (index < 3) {
Document.write("Beetlejuice ");
Index = index + 1;
}

B) var index = 1;
While (index < 3) {
Document.write("Beetlejuice ");
Index == index + 1;
}

C) var index = 0;
While (index <= 3) {
Document.write("Beetlejuice ");
Index = index + 1;
}

D) var index = 0;
While (index = 3) {
Document.write("Beetlejuice ");
Index = index + 1;
}
Question
The loop that displays all even numbers from 0 to 18 is ____.

A) Declare Numeric evenNum = 1
While evenNum <= 18
Display evenNum
EvenNum = evenNum + 2
End While

B) Declare Numeric evenNum = 0
While evenNum <= 18
Display evenNum
EvenNum = evenNum + 2
End While

C) Declare Numeric evenNum = 1
While evenNum < 18
Display evenNum
EvenNum = evenNum + 2
End While

D) Declare Numeric evenNum = 0
While evenNum = 18
Display evenNum
EvenNum = evenNum + 2
End While
Question
Subtracting values from a loop variable is called ____.

A) evaluating
B) incrementing
C) nesting
D) decrementing
Question
Which of the following loops counts backwards from 20 to 10?

A) Declare Numeric countDown = 20
While countdown > 0
Display countDown
CountDown = countDown - 1
End While

B) Declare Numeric countDown = 20 While countdown > 10
Display countDown
CountDown = countDown - 1
End While

C) Declare Numeric countDown = 20 While countdown = 10
Display countDown
CountDown = countDown - 1
End While

D) Declare Numeric countDown = 20 While countdown > 9
Display countDown
CountDown = countDown - 1
End While
Question
Which of the following loops displays all numbers from 0 to 40 in increments of 5?

A) Declare Numeric num = 0
While evenNum <= 40
Display num
Num = num + 5
End While

B) Declare Numeric num = 0 While num = 40
Display num
Num = num + 5
End While

C) Declare Numeric num = 1 While num < 40
Display num
Num = num + 5
End While

D) Declare Numeric num = 1 While num = 40
Display num
Num = num + 5
End While
Question
When using counters and loop variables that are incremented and decremented by a fixed amount, you can determine ahead of time how many times the loop should iterate. This kind of loop is called a(n) ____.

A) infinite loop
B) indeterminate loop
C) determinate loop
D) nested loop
Question
A(n) ____ is a prompt used before a loop starts to determine whether to enter it the first time.

A) sentinel value
B) priming prompt
C) subscript
D) increment operator
Question
A(n) ____ is a predefined value used to signal the end of valid data input in a loop.

A) sentinel value
B) counter
C) accumulator
D) increment operator
Question
What is the sentinel value in the following loop?
Declare Numeric invoiceNum
Declare Numeric senValue
Display "Enter an invoice number or -1 to quit: "
Input invoiceNum
While invoiceNum != -1
[more processing statements]
Display "Enter another invoice number or -1 to quit: "
Input invoiceNum
End While

A) invoiceNum
B) Input
C) senValue
D) -1
Question
A(n) ____ is one in which the condition is evaluated after the body of the loop.

A) infinite loop
B) nested loop
C) posttest loop
D) pretest loop
Question
The most common posttest loop is the ____.

A) Do While loop
B) For loop
C) nested loop
D) While loop
Question
<strong>   -The accompanying flowchart represents a(n) ____.</strong> A) For loop B) infinite loop C) pretest loop D) Do While loop <div style=padding-top: 35px>

-The accompanying flowchart represents a(n) ____.

A) For loop
B) infinite loop
C) pretest loop
D) Do While loop
Question
A variation of the While loop was developed to combine all three loop control components and place them on the same line: the ____.

A) For loop
B) posttest loop
C) indefinite loop
D) indeterminate loop
Question
Which of the following loops prints "Happy Birthday!" 10 times?

A) For count = 0 To 10
Display "Happy Birthday!"
End For

B) For count = 1 To 10
Display "Happy Birthday!"
End For

C) While count = 1 To 10
Display "Happy Birthday!"
End While

D) Do While count = 1 To 10
Display "Happy Birthday!"
End While
Question
In JavaScript, the ____ consists of two plus signs (++) appended to the variable name and causes the computer to add 1 to the variable's value.

A) accumulator
B) Boolean operator
C) increment operator
D) decrement operator
Question
In a(n) ____, the inner loop performs all its iterations for every iteration of the outer loop.

A) nested loop
B) pretest loop
C) posttest loop
D) infinite loop
Question
The following is an example of a(n) ____.
For hours = 0 to 23
For minutes = 0 to 59
For seconds = 0 to 59
Display hours + ":" + minutes + ":" + seconds
End For
End For
End For

A) nested loop
B) posttest loop
C) indeterminate loop
D) infinite loop
Question
A company wants you to input quarterly sales figures for sales employees. The loop that does this is ____.

A) Display "Enter the number of salespeople: "
Input numSalespeople
For qtrIndex = 1 To 4
Display empIndex + ", quarter " + qtrIndex
Input salesAmt
End For

B) Display "Enter the number of salespeople: "Input numSalespeopleFor empIndex = 1 To numSalespeopleDisplay empIndex + ", quarter " + qtrIndexInput salesAmtEnd For

C) Display "Enter the number of salespeople: "Input numSalespeopleFor empIndex = 1 To numSalespeopleFor qtrIndex = 1 To 4Display empIndex + ", quarter " + qtrIndexInput salesAmtEnd ForEnd For

D) Display "Enter the number of salespeople: "For empIndex = 1 To numSalespeopleFor qtrIndex = 1 To 4Display empIndex + ", quarter " + qtrIndexInput salesAmtEnd ForEnd For
Question
A(n) ____ is a loop variable to which amounts are added; also called a "running total."

A) operator
B) sentinel
C) flag
D) accumulator
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 6: The Repetition Structure
1
After the statements in a loop are performed, the condition is evaluated again; depending on the evaluation's outcome, the statements might be performed again.
True
2
Loops are commonly used to perform a task a specified number of times.
True
3
Looping allows you to use one set of instructions to process multiple sets of data.
True
4
A counter is numeric and often named value.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
The most common repetition structure is the For loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
On a flowchart, if you have a condition leading to statements on the true branch (or on both the true and false branches), but the flowline does not go back to the condition, it is a While loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
On a flowchart, if you have a condition leading to statements on the true branch, and the flowline goes back to the condition, it is an If (or If/Else) statement.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
With a determinate loop, you do not know the number of iterations ahead of time.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
An infinite loop is one that never ends.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
Continue is a reserved keyword in many languages, so it cannot be used as a variable name.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
The body of a pretest loop is always executed at least once.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
The Do While loop has only one entrance and one exit.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
In a While loop, the condition is at the beginning, guarding the entry point to the loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
In a JavaScript While loop, there is no semicolon after the condition.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
Loops have three components: initialization, condition testing, and validation.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
In a While loop, the loop variable can be initialized at any place in the program before the condition.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
In the Do While loop, the statement initializing the loop variable is usually the same statement that alters it.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
The decrement operator is ==.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
The Break statement is the only way to prevent the rest of the code from being performed.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
The Break statement cannot be used in a While or a Do While loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
The Break statement causes program control to skip immediately to the first statement after the end of the loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
When a Continue statement is used in a While or Do While loop, program control goes immediately to the beginning of the loop and starts a new iteration.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
In order to use a static variable or call a static method, you must create a separate object from the class.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
To call a static method in pseudocode, you use the keyword Call, the class name, a period (called a dot), the method name, and any arguments in parentheses.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
In JavaScript, you do not have to declare instance variables separately in the <head> section of the HTML file. They are declared automatically when the constructor method is called.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
The ____ is a section of programming instructions performed, perhaps repeatedly (and as many times as needed), as the result of a condition.

A) repetition structure
B) accumulator
C) increment operator
D) sentinel value
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
Each performance (or execution) of the statements in a loop is called a(n) ____ of the loop.

A) iteration
B) accumulation
C) alteration
D) initialization
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
A(n) ____ is a loop that never stops.

A) closed loop
B) infinite loop
C) enclosed loop
D) nested loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
Adding to the value of a variable is known as ____ the variable.

A) evaluating
B) nesting
C) incrementing
D) decrementing
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
The loop for displaying "Beetlejuice" three times is ____.

A) Declare Numeric index = 1
While index < 3
Display "Beetlejuice"
Index = index + 1
End While

B) Declare Numeric index = 0
While index == 3
Display "Beetlejuice"
Index = index + 1
End While

C) Declare Numeric index = 0
While index <= 3
Display "Beetlejuice"
Index = index + 1
End While

D) Declare Numeric index = 0
While index < 3
Display "Beetlejuice"
Index = index + 1
End While
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
When a condition is evaluated before any statements are performed, the While loop is considered a(n) ____.

A) nested loop
B) pretest loop
C) posttest loop
D) infinite loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
The JavaScript code for displaying "Beetlejuice" three times is ____.

A) var index = 0;
While (index < 3) {
Document.write("Beetlejuice ");
Index = index + 1;
}

B) var index = 1;
While (index < 3) {
Document.write("Beetlejuice ");
Index == index + 1;
}

C) var index = 0;
While (index <= 3) {
Document.write("Beetlejuice ");
Index = index + 1;
}

D) var index = 0;
While (index = 3) {
Document.write("Beetlejuice ");
Index = index + 1;
}
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
The loop that displays all even numbers from 0 to 18 is ____.

A) Declare Numeric evenNum = 1
While evenNum <= 18
Display evenNum
EvenNum = evenNum + 2
End While

B) Declare Numeric evenNum = 0
While evenNum <= 18
Display evenNum
EvenNum = evenNum + 2
End While

C) Declare Numeric evenNum = 1
While evenNum < 18
Display evenNum
EvenNum = evenNum + 2
End While

D) Declare Numeric evenNum = 0
While evenNum = 18
Display evenNum
EvenNum = evenNum + 2
End While
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
Subtracting values from a loop variable is called ____.

A) evaluating
B) incrementing
C) nesting
D) decrementing
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
Which of the following loops counts backwards from 20 to 10?

A) Declare Numeric countDown = 20
While countdown > 0
Display countDown
CountDown = countDown - 1
End While

B) Declare Numeric countDown = 20 While countdown > 10
Display countDown
CountDown = countDown - 1
End While

C) Declare Numeric countDown = 20 While countdown = 10
Display countDown
CountDown = countDown - 1
End While

D) Declare Numeric countDown = 20 While countdown > 9
Display countDown
CountDown = countDown - 1
End While
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
Which of the following loops displays all numbers from 0 to 40 in increments of 5?

A) Declare Numeric num = 0
While evenNum <= 40
Display num
Num = num + 5
End While

B) Declare Numeric num = 0 While num = 40
Display num
Num = num + 5
End While

C) Declare Numeric num = 1 While num < 40
Display num
Num = num + 5
End While

D) Declare Numeric num = 1 While num = 40
Display num
Num = num + 5
End While
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
When using counters and loop variables that are incremented and decremented by a fixed amount, you can determine ahead of time how many times the loop should iterate. This kind of loop is called a(n) ____.

A) infinite loop
B) indeterminate loop
C) determinate loop
D) nested loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
A(n) ____ is a prompt used before a loop starts to determine whether to enter it the first time.

A) sentinel value
B) priming prompt
C) subscript
D) increment operator
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
A(n) ____ is a predefined value used to signal the end of valid data input in a loop.

A) sentinel value
B) counter
C) accumulator
D) increment operator
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
What is the sentinel value in the following loop?
Declare Numeric invoiceNum
Declare Numeric senValue
Display "Enter an invoice number or -1 to quit: "
Input invoiceNum
While invoiceNum != -1
[more processing statements]
Display "Enter another invoice number or -1 to quit: "
Input invoiceNum
End While

A) invoiceNum
B) Input
C) senValue
D) -1
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
A(n) ____ is one in which the condition is evaluated after the body of the loop.

A) infinite loop
B) nested loop
C) posttest loop
D) pretest loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
The most common posttest loop is the ____.

A) Do While loop
B) For loop
C) nested loop
D) While loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
<strong>   -The accompanying flowchart represents a(n) ____.</strong> A) For loop B) infinite loop C) pretest loop D) Do While loop

-The accompanying flowchart represents a(n) ____.

A) For loop
B) infinite loop
C) pretest loop
D) Do While loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
A variation of the While loop was developed to combine all three loop control components and place them on the same line: the ____.

A) For loop
B) posttest loop
C) indefinite loop
D) indeterminate loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
Which of the following loops prints "Happy Birthday!" 10 times?

A) For count = 0 To 10
Display "Happy Birthday!"
End For

B) For count = 1 To 10
Display "Happy Birthday!"
End For

C) While count = 1 To 10
Display "Happy Birthday!"
End While

D) Do While count = 1 To 10
Display "Happy Birthday!"
End While
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
In JavaScript, the ____ consists of two plus signs (++) appended to the variable name and causes the computer to add 1 to the variable's value.

A) accumulator
B) Boolean operator
C) increment operator
D) decrement operator
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
In a(n) ____, the inner loop performs all its iterations for every iteration of the outer loop.

A) nested loop
B) pretest loop
C) posttest loop
D) infinite loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
The following is an example of a(n) ____.
For hours = 0 to 23
For minutes = 0 to 59
For seconds = 0 to 59
Display hours + ":" + minutes + ":" + seconds
End For
End For
End For

A) nested loop
B) posttest loop
C) indeterminate loop
D) infinite loop
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
A company wants you to input quarterly sales figures for sales employees. The loop that does this is ____.

A) Display "Enter the number of salespeople: "
Input numSalespeople
For qtrIndex = 1 To 4
Display empIndex + ", quarter " + qtrIndex
Input salesAmt
End For

B) Display "Enter the number of salespeople: "Input numSalespeopleFor empIndex = 1 To numSalespeopleDisplay empIndex + ", quarter " + qtrIndexInput salesAmtEnd For

C) Display "Enter the number of salespeople: "Input numSalespeopleFor empIndex = 1 To numSalespeopleFor qtrIndex = 1 To 4Display empIndex + ", quarter " + qtrIndexInput salesAmtEnd ForEnd For

D) Display "Enter the number of salespeople: "For empIndex = 1 To numSalespeopleFor qtrIndex = 1 To 4Display empIndex + ", quarter " + qtrIndexInput salesAmtEnd ForEnd For
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
A(n) ____ is a loop variable to which amounts are added; also called a "running total."

A) operator
B) sentinel
C) flag
D) accumulator
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 50 flashcards in this deck.