Quiz4-RepetitionStructures Flashcards
The following pseudocode is for a loop that will perform three iterations: (T/F)
For start = 6 To 2 step -3
Do something
End For
False. iterations is 2x
meaning 6-3=3
3-3= 0
The following pseudocode is for a loop that will perform three iterations: (T/F)
For start = 5 To 10 Step 2
Do something
End For
True:
start at 5 skip 2.
UNTIL value is 10.
5+2=7
7+2=9
9+2=11
STOP ITERATIONS BC 11>10
The Do-While loop is a posttest loop (T/F)
True
The while loop gets its name from the way it works: it does a task WHILE a condition is false (T/F)
False
while a condition is TRUE.
The test condition in a While loop must always be an integer value(T/F)
False
A while loop repeats infinitely when there is no statement inside the loop body that will make the test condition false(T/F)
True
For loops automatically increment or decrement a counter variable(T/F)
True
You can only use positive integers as step values in a For statement(T/F)
False
In a For loop the programmer must know the exact number of iterations the loop must perform before writing the code(T/F)
False
While and For loops are considered pretest loops because they test the condition before processing the statement or statements in the loop body(T/F)
True
A condition-controlled loop can be used to iterate the body of the loop a specific number of times(T/F)
True
In the following pseudocode counter is the accumulator(T/F):
For counter = 1 to 6
Set numberWidgets=numberwidgets+counter
End For
False:
The variable numberofwigdets is used as an accumulator to keep track of a running total as the loop iterates. The accumulator is incremented by the value of counter on each iteration of the loop.
After the loop has completed, the final value of the accumulator would be the sum of the numbers from 1 to 6
Which of the following is the structure that causes a statement or set of statements to execute repeatedly?
repetition structure
Which type of loop uses a Boolean expression to control the number of times a loop repeats?
Condition-Controlled loop
Which type of loop repeats a statement or set of statements as long as the Boolean expression IS FALSE?
Do-Until
Which type of loop is specifically designed to initialize, test, and increment or decrement a counter variable?
For loops
The amount by which the counter variable is incremented or decremented in a For loop is known as the:
Step amount
A loop that accumulates a total as it reads each number from a series is often said to keep a(n):
running total