Deck 5: Looping
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
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/59
Play
Full screen (f)
Deck 5: Looping
1
Use a counter or a(n)____ to control a loop's repetitions.
A) sentinel variable
B) end value
C) sentinel value
D) end statement
A) sentinel variable
B) end value
C) sentinel value
D) end statement
C
2
An indefinite loop is a loop that never stops.
False
3
A mistake programmers often make with loops is that they ____.
A) initialize the loop control variable prior to entering the loop body
B) increment the loop control variable inside of the loop body
C) include statements inside the loop that belong outside the loop
D) enclose the inner loop entirely within the outer loop in a nested loop
A) initialize the loop control variable prior to entering the loop body
B) increment the loop control variable inside of the loop body
C) include statements inside the loop that belong outside the loop
D) enclose the inner loop entirely within the outer loop in a nested loop
C
4
The safest action is to assign the value 1 to accumulators before using them.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
5
The loop control variable is initialized after entering the loop.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
6
A(n)____ is any numeric variable you use to count the number of times an event has occurred.
A) accumulator
B) key
C) index
D) counter
A) accumulator
B) key
C) index
D) counter
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
7
A loop within another loop is known as a(n)____ loop.
A) indefinite
B) infinite
C) nested
D) hidden
A) indefinite
B) infinite
C) nested
D) hidden
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
8
When one loop appears inside another,the loop that contains the other loop is called the ____ loop.
A) indefinite
B) definite
C) inner
D) outer
A) indefinite
B) definite
C) inner
D) outer
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
9
Every high-level computer programming language contains a while statement.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
10
The first step in a while loop is typically to ____.
A) compare the loop control variable to a constant value
B) initialize the loop control variable
C) increment the loop control variable
D) execute the body of the loop
A) compare the loop control variable to a constant value
B) initialize the loop control variable
C) increment the loop control variable
D) execute the body of the loop
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
11
Usually,when you create nested loops,each loop has its own ____.
A) sentinel value
B) goto statement
C) entrance condition
D) loop control variable
A) sentinel value
B) goto statement
C) entrance condition
D) loop control variable
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
12
Forgetting to initialize and alter the loop control variable are common mistakes that programmers sometimes make.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
13
Both the while loop and the for loop are examples of pretest loops.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
14
You can either increment or decrement the loop control variable.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
15
A(n)____ loop executes a predetermined number of times.
A) terminal
B) definite
C) indefinite
D) infinite
A) terminal
B) definite
C) indefinite
D) infinite
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
16
Once your logic enters the body of a structured loop,____.
A) the entire loop must execute
B) the loop can be terminated with a break statement
C) the loop will execute indefinitely
D) a decision statement will be evaluated
A) the entire loop must execute
B) the loop can be terminated with a break statement
C) the loop will execute indefinitely
D) a decision statement will be evaluated
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
17
In some cases,a loop control variable does not have to be initialized.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
18
Many loop control variable values are altered by ____,or adding to them.
A) incrementing
B) decrementing
C) accumulating
D) deprecating
A) incrementing
B) decrementing
C) accumulating
D) deprecating
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
19
When one loop appears inside another is is called an indented loop.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
20
It is the programmer's responsibility to initialize all variables that must start with a specific value.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
21
A posttest loop is sometimes called a ____________________ loop.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
22
____________________ can ensure that a value is the correct data type or that it falls within an acceptable range.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
23
Programmers employ the acronym ____ to mean that if your input is incorrect,your output is worthless.
A) IBOW
B) GIGO
C) IIOW
D) GIGS
A) IBOW
B) GIGO
C) IIOW
D) GIGS
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
24
A comparison is correct only when the correct ____ and operator are used.
A) expression
B) operands
C) statements
D) index
A) expression
B) operands
C) statements
D) index
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
25
To add to a variable is to ____________________ the variable.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
26
____ is a technique with which you try to prepare for all possible errors before they occur.
A) Incrementing
B) Stub
C) Nested loop
D) Defensive programming
A) Incrementing
B) Stub
C) Nested loop
D) Defensive programming
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
27
You usually use the for loop with ____ loops.
A) indefinite
B) definite
C) inner
D) outer
A) indefinite
B) definite
C) inner
D) outer
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
28
____ a data item means you override incorrect data by setting the variable to a specific value.
A) Flexing
B) Tracing
C) Forcing
D) Blanking
A) Flexing
B) Tracing
C) Forcing
D) Blanking
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
29
____________________ are frequently used to accumulate totals and to validate data.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
30
In a ____,the loop body executes at least one time because the loop control variable is not tested until after one iteration.
A) nested loop
B) pretest loop
C) posttest loop
D) loop control
A) nested loop
B) pretest loop
C) posttest loop
D) loop control
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
31
Business reports that list only totals,with no individual item details,are called ____.
A) detail reports
B) summary reports
C) transaction reports
D) control-break reports
A) detail reports
B) summary reports
C) transaction reports
D) control-break reports
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
32
The amount by which a for loop control variable changes is often called a ____ value.
A) group
B) key
C) step
D) sentinel
A) group
B) key
C) step
D) sentinel
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
33
Programmers use the term ____ to describe programs that are well designed and easy to understand and maintain.
A) industrial
B) intractable
C) well behaved
D) elegant
A) industrial
B) intractable
C) well behaved
D) elegant
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
34
In a for statement,a loop control variable is initialized,tested,and ____________________.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
35
The ____ loop is particularly useful when processing arrays.
A) for
B) while
C) infinite
D) nested
A) for
B) while
C) infinite
D) nested
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
36
In a ____,the loop body might never execute because the question controlling the loop might be false the first time it is asked.
A) summary report
B) pretest loop
C) posttest loop
D) loop control
A) summary report
B) pretest loop
C) posttest loop
D) loop control
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
37
A mistake programmers often make with loops is that they ____.
A) neglect to initialize the loop control variable prior to entering the loop body
B) increment the loop control variable inside of the loop body
C) validate data to ensure values are the correct data type or that they fall within an acceptable range
D) enclose the inner loop entirely within the outer loop in a nested loop
A) neglect to initialize the loop control variable prior to entering the loop body
B) increment the loop control variable inside of the loop body
C) validate data to ensure values are the correct data type or that they fall within an acceptable range
D) enclose the inner loop entirely within the outer loop in a nested loop
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
38
The ____ loop provides three actions in one compact statement.
A) for
B) while
C) do until
D) repeat
A) for
B) while
C) do until
D) repeat
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
39
Loops are frequently used to ____;that is,to make sure it is meaningful and useful.
A) validate data
B) restructure data
C) simulate data
D) corroborate data
A) validate data
B) restructure data
C) simulate data
D) corroborate data
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
40
A(n)____ is very similar to a counter that you use to count loop iterations,except that you usually add a value other than one to this type of variable.
A) transaction
B) total
C) validator
D) accumulator
A) transaction
B) total
C) validator
D) accumulator
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
41
Explain when it would be appropriate to write an indefinite loop.
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
42
Match each term with a statement below.
-To add to a variable
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
-To add to a variable
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
43
When are you required to use a for statement,and what are the advantages of for statements?
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
44
What are common mistakes made by programmers in coding loops?
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
45
How might user data be validated?
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
46
Match each term with a statement below.
-The amount by which a for loop control variable changes
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
-The amount by which a for loop control variable changes
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
47
What is the difference between a definite loop and an indefinite loop?
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
48
What is an accumulator?
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
49
Match each term with a statement below.
-To override incorrect data by setting the variable to a specific,predetermined value
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
-To override incorrect data by setting the variable to a specific,predetermined value
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
50
Match each term with a statement below.
-Any numeric variable you use to count the number of times an event has occurred
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
-Any numeric variable you use to count the number of times an event has occurred
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
51
What is a step value?
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
52
Match each term with a statement below.
-One set of instructions that operates on multiple,separate sets of data
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
-One set of instructions that operates on multiple,separate sets of data
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
53
What are the tasks performed by the for count = 0 to 3 statement?
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
54
Match each term with a statement below.
-A variable that you use to gather values
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
-A variable that you use to gather values
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
55
Match each term with a statement below.
-A loop that may execute a different number of times each time the program executes
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
-A loop that may execute a different number of times each time the program executes
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
56
What is an advantage of using fewer instructions?
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
57
Match each term with a statement below.
-To decrease a variable's value
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
-To decrease a variable's value
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
58
Match each term with a statement below.
-Loops within loops
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
-Loops within loops
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck
59
Match each term with a statement below.
-Initialized before entering a while loop
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
-Initialized before entering a while loop
A)indefinite
B)loop control variable
C)nested loops
D)counter
E)increment
F)decrement
G)accumulator
H)loop
I)step value
J)forcing
Unlock Deck
Unlock for access to all 59 flashcards in this deck.
Unlock Deck
k this deck