M3 CH5 Flashcards
A ____________________________ - controlled loop uses a true/false condition to control the number of times that it repeats.
Boolean
condition
decision
count
condition
A __________________________- controlled loop repeats a specific number of times.
Boolean
condition
decision
count
count
Each repetition of a loop is known as a(n) ______________________________.
cycle
revolution
orbit
iteration
iteration
The While loop is a _______________________ type of loop.
pretest
postest
prequalified
post iterative
pretest
The Do-While loop is a ______________________type of loop.
pretest
posttest
prequalified
post iterative
posttest
The For loop is a ______________________________________ type of loop.
pretest
posttest
prequalified
post iterative
pretest
A(n) _______________________________ loop has no way of ending and repeats until the program is interrupted.
indeterminate
interminable
infinite
timeless
infinite
A __________________________ loop always executes at least once.
pretest
postest
condition-controlled
count-controlled
postest
A(n) ________________________________ is a special value that signals when there are no more items from a list of items to be processed. This value cannot be mistaken as an item from the list.
sentinel
flag
signal
accumulator
sentinel
A condition-controlled loop always repeats a specific number of times.
True or False
False
The While loop is a pretest loop
True or False
True
The Do-While loop is a pretest loop.
True or False
False
You should not write code that modifies the contents of the counter variable in the body of a For loop.
True
You cannot display the contents of the counter variable in the body of a loop.
True or False
False
It is not possible to increment a counter variable by any value other than 1.
True or False
False
The following statement decrements the variable x: Set x = x - 1.
True or False
True
It is not necessary to initialize accumulator variables.
True or False.
False
In a nested loop, the inner loop goes through all of its iterations for every single iteration of the outer loops.
True or False
True
To calculate the total number of iterations of a nested loop, add the number of iterations of all the loops.
True or False
False
Why should you indent the statements in the body of a loop?
By indenting the that statements in the body of the loop you visually set them apart from the surrounding code. This makes your program easier to read and debug. Also, this is similar to the style that most programmers follow when writing loops in actual code.
Describe the difference between pretest loops and posttest loops.
Pretest loops tests its condition before performing an iteration. Because the test is done at the beginning of the loop, you usually have to perform some steps prior to the loop to make sure that the loop executes at least once.
Posttest loops performs an iteration before testing its condition. The posttest loop always perform at least once iteration even if its condition is false to begin with.
What is a condition-controlled loop?
A condition-contrlled loop uses a true/false condition to control the number of times that it repeats.
What is a count-controlled loop?
A count-controlled loop iterates a specific number of times.
What is an infinite loop? Write the code for an infinite loop.
An infinite loop continues to repeat until the program is interrupted. Infinite loops usually occur when the programmer forgets to write code inside the loop that makes the test condition false.
Declare Integer awesome = 5
While awesome > 0
set awesome = awesome + 1
display awesome
End While