chapter 5 Flashcards
When you use a loop, you can write one set of instructions that operates on multiple, separate sets of data.
true
A major advantage of having a computer perform complicated tasks is the ability to repeat them.
true
A loop is a structure that branches in two logical paths before continuing.
false
To make a while loop execute correctly, a loop control variable must be set to 0 before entering the loop.
false
To make a while loop execute correctly, a loop control variable should be tested before entering the loop body.
true
To make a while loop execute correctly, the body of the loop must take some action that alters the value of the loop control variable.
true
When one loop is nested inside another, the loop that contains the other loop is called the outer loop.
true
You need to create nested loops when the values of two or more variables repeat to produce every combination of values.
true
The number of times a loop executes always depends on a constant.
false
In a loop, neglecting to initialize the loop control variable is a mistake.
true
In a loop, neglecting to alter the loop control variable is a mistake.
true
In a loop, comparing the loop control variable using >= or <= is a mistake.
false
The for statement provides you with three actions in one compact statement: initializing, testing, and altering a loop control variable.
true
A for statement body always executes at least one time.
false
In most programming languages, you can provide a for loop with any step value.
true
In a while loop, the loop body might not execute.
true
In a do-while loop, the loop body might not execute.
false
The logic expressed by a do-while loop can always be expressed using a sequence and a while loop.
true
In a structured loop, the loop-controlling evaluation must provide either the entry to or exit from the repeating structure.
true
In a structured loop, the loop-controlling evaluation provides the only entry to or exit from the structure.
true
If you need to perform a task, evaluate a condition, and perform an additional task, you cannot use a structured loop.
false
An accumulator is a variable that you use to gather or accumulate values.
true
An accumulator typically is initialized to 0.
true
An accumulator is typically reset to 0 after it is output.
false
Selection and loop structures differ in that selection structures only take action when a test condition is true.
false
Selection and loop structures are similar in that the tested condition that begins either structure always has two possible outcomes.
true
One difference between selection and loop structures is that the structure-controlling evaluation is repeated in a loop structure.
true