Deck 5: Repetition Statements
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/50
Play
Full screen (f)
Deck 5: Repetition Statements
1
The line total = total + num is an example of a(n) ____ statement.
A) initialization
B) declaration
C) accumulating
D) definition
A) initialization
B) declaration
C) accumulating
D) definition
C
2
In a(n) ____ loop, the condition is tested before any statements in the loop are executed.
A) posttest
B) pretest
C) prior
D) early-test
A) posttest
B) pretest
C) prior
D) early-test
B
3
The do while construct is an example of a posttest loop.
True
4
The construction for ( ; count is invalid.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
5
Combining interactive data entry with the repetition capabilities of the while statement produces adaptable and powerful programs.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
6
A(n) ____ loop is a loop that never ends.
A) fixed
B) controlled
C) infinite
D) finite
A) fixed
B) controlled
C) infinite
D) finite
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
7
A(n) ____ statement both defines the boundaries containing the repeating section of code and controls whether the code will be executed.
A) declaration
B) selection
C) arithmetic
D) repetition
A) declaration
B) selection
C) arithmetic
D) repetition
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
8
As a general rule, the continue statement is less useful than the break statement.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
9
Entering data interactively in a loop is a general technique that s applicable to for loops.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
10
In C++, continue produces the same action for both while and for statements.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
11
Three different forms of repetition statements are provided in C++: while , ____, and do while .
A) for
B) if-else
C) switch
D) if-else chain
A) for
B) if-else
C) switch
D) if-else chain
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
12
____ loops always execute the loop statements at least once before the condition is tested.
A) Pretest
B) Posttest
C) entrance-controlled
D) beforetest
A) Pretest
B) Posttest
C) entrance-controlled
D) beforetest
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
13
The do statement is particularly useful in filtering user-entered input and providing data validation checks.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
14
C++ s for statement is virtually interchangeable with its while statement.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
15
In C++, a ____ loop is constructed using a while statement.
A) while
B) whereas
C) do
D) switch
A) while
B) whereas
C) do
D) switch
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
16
A loop that evaluates a condition at the end of the repeating section of code is referred to as a(n) ____ loop.
A) entrance-controlled
B) pretest
C) exit-controlled
D) aftertest
A) entrance-controlled
B) pretest
C) exit-controlled
D) aftertest
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
17
The for statement performs the same functions as the while statement, but uses a different form.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
18
In a ____ loop, the condition is used to keep track of how many repetitions have occurred.
A) pretest
B) posttest
C) variable-condition
D) fixed-count
A) pretest
B) posttest
C) variable-condition
D) fixed-count
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
19
Both the ____ and for loop structures are examples of entrance-controlled loops.
A) while
B) switch
C) do while
D) if-else
A) while
B) switch
C) do while
D) if-else
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
20
Loop structures can evaluate the condition only at the beginning of the repeating section of code.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
21
Values used to control a loop can be set by using ____.
A) variables
B) constants
C) conditional statements
D) either a or b
A) variables
B) constants
C) conditional statements
D) either a or b
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
22
The ____ error means the loop executes either one too many or one too few times than was intended.
A) miscalculation
B) off by one
C) less-count
D) too-many-few
A) miscalculation
B) off by one
C) less-count
D) too-many-few
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
23
In C++, a ____ loop is constructed using a for statement.
A) for
B) time
C) selection
D) switch
A) for
B) time
C) selection
D) switch
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
24
Inside the parentheses of the for statement are three items, separated by ____.
A) dots
B) commas
C) colons
D) semicolons
A) dots
B) commas
C) colons
D) semicolons
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
25
When ____ is encountered in a loop, the next iteration of the loop begins immediately.
A) goto
B) go
C) resume
D) continue
A) goto
B) go
C) resume
D) continue
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
26
Posttest loops can be constructed in C++ using ____ loops.
A) while
B) do while
C) for
D) if-else chain
A) while
B) do while
C) for
D) if-else chain
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
27
A(n) _______________ statement defines the boundaries of a repeating section of code and controls whether the code is executed.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
28
In C++, a posttest loop can be created by using a(n) ____ statement.
A) if
B) case
C) do
D) for
A) if
B) case
C) do
D) for
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
29
A(n) ____________________ loop s test condition evaluates to a non-zero value on every repetition.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
30
A common programming technique is to use a for or ____ loop to cycle through a set of numbers and select numbers meeting one or more criteria.
A) while
B) if-else
C) switch
D) break
A) while
B) if-else
C) switch
D) break
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
31
In a(n) ____________________-condition loop, the tested condition doesn t depend on a count being reached; instead, it continues until a specified value is encountered.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
32
In computer programming, data values used to signal the start or end of a data series are called ____.
A) sentinels
B) marks
C) dummies
D) interrupts
A) sentinels
B) marks
C) dummies
D) interrupts
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
33
A semicolon with nothing preceding it is also a valid statement, called the ____ statement.
A) empty
B) null
C) blank
D) void
A) empty
B) null
C) blank
D) void
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
34
A(n) ____ statement forces an immediate exit from the switch , while , for and do-while statements.
A) exit
B) break
C) stop
D) halt
A) exit
B) break
C) stop
D) halt
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
35
Entrance-controlled loops are also referred to as ____________________ loops.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
36
Typically, null statements are used with while or ____ statements.
A) if-else
B) switch
C) for
D) case
A) if-else
B) switch
C) for
D) case
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
37
C++ s ____________________ statement is virtually interchangeable with its while statement.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
38
A loop contained within another loop is called a ____ loop.
A) compound
B) composed
C) complex
D) nested
A) compound
B) composed
C) complex
D) nested
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
39
In Visual Basic and Pascal, the for statement can be used only to construct ____ loops.
A) posttest
B) exit-controlled
C) fixed-count
D) variable-condition
A) posttest
B) exit-controlled
C) fixed-count
D) variable-condition
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
40
A(n) ____ forces control to be passed to the altering list in a for statement.
A) exit
B) continue
C) interrupt
D) next
A) exit
B) continue
C) interrupt
D) next
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
41
Inside the parentheses of the for statement, the ____________________ list provides the increment value that s added to or subtracted from the counter each time the loop is executed.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
42
The semicolon at the end of the statement for (count = 0; count is called a(n) ____________________ statement.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
43
The ____________________ statement violates pure structured programming principles because it provides a second, nonstandard exit from a loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
44
In computer programming, a data value used to signal the start or end of a data series is called a(n) ____________________.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
45
In C++, the ____________________ statement can replace or be replaced by an equivalent while or for statement.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
46
A common programming error is omitting the final ____________________ from the do statement.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
47
When a(n) ____________________ statement is encountered in a loop, the next iteration of the loop begins immediately.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
48
A(n) ____________________ statement is used where a statement is required syntactically, but no action is called for.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
49
A do while loop is an example of a(n) ____________________-controlled loop.
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck
50
The loop created by the statement for (i = 0; i executes ____________________ times
Unlock Deck
Unlock for access to all 50 flashcards in this deck.
Unlock Deck
k this deck