Quiz 4
How many times would the following loop iterate? Set k = 1 While k > 5 Display k End While
0
If the following pseudocode were coded and executed, assuming all variables have been declared as integers, what would be the display? Set x = 0 For m = 1 To 3 For p = 1 to 3 Set x = x + p End For End For Display x
18
How many times would the following loop iterate? Set k = 1 Do Display k Set k = k +1 Until k > 2
2
How many times would the following loop iterate? For j = 1 To 5 Step 2 Display j End For
3
How many times would the following loop iterate? For m = 1 To 8 Step 3 Display m End For
3
A loop that iterates as long as a condition is false and then stops when the condition becomes true is known as a(n) ________ loop.
Do-Until
Which type of loop repeats a statement or set of statements as long as the Boolean expression is false?
Do-Until
Select all that apply. Which of the following are posttest loops?
Do-While, Do-Until
In a For loop the programmer must know the exact number of iterations the loop must perform before writing the code.
False
In the following pseudocode counter is the accumulator. For counter = 1 to 6 Set numberWidgets = numberWidgets + counter End For
False
The While loop gets its name from the way it works: It does a task while a condition is false.
False
The following pseudocode is for a loop that will perform three iterations. For start = 6 To 2 Step -3 Do something End For
False
The test condition in a While loop must always be an integer value.
False
You can only use positive integers as step values in a For statement.
False
The ________ statement is specifically designed to initialize, test, and increment or decrement a counter variable.
For
Which type of loop is specifically designed to initialize, test, and increment or decrement a counter variable?
For
If an expression is False, the ________ operator will return True.
NOT
A While loop repeats infinitely when there is no statement inside the loop body that will make the test condition false.
True
A condition-controlled loop can be used to iterate the body of the loop a specific number of times.
True
For loops automatically increment or decrement a counter variable.
True
The Do-While loop is a posttest loop.
True
The following pseudocode is for a loop that will perform three iterations. For start = 5 To 10 Step 2 Do something End For
True
While and For loops are considered pretest loops because they test the condition before processing the statement or statements in the loop body.
True
When a(n) ________ loop executes, the condition is tested at the beginning. If it is true, the loop body executes and the loop starts over. If it is false, the loop terminates.
While
Select all that apply. Which of the following cause(s) a statement or set of statements to repeat as long as a condition is true?
While loops, Do-While loops
The variable that keeps a running total in a loop is known as a(n) ________.
accumulator
Which type of loop uses a Boolean expression to control the number of times a loop repeats?
condition-controlled
A(n) ________-controlled loop repeats a statement or set of statements a specific number of times.
count
The following is an example of a ________ loop. While x < 10 Set sum = sum + x Set x = x + 1 End While
count-controlled
A count-controlled loop uses a variable known as a(n) ________ to store the number of iterations that have been performed.
counter
In a For loop, a negative step value is used to ________ the counter variable.
decrement
A(n) ________ loop continues to repeat until the program is interrupted.
infinite
How many times would the following loop iterate? Set k = 1 While k < 5 Display k Set k = k + 1 End While
infinite
How many times would the following loop iterate? Set k = 1 While k <= 5 Display k End While
infinite
The total number of ________ of a nested loop is the product of the number of iterations of all the loops.
iterations or repetitions
Statements that appear between the While and End While statements are known as the ________.
loop body
In a count-controlled loop, the test action compares the counter variable to the ________ value to determine if the loop iterates or terminates.
maximum
A structure that has a loop inside another loop is called a(n) ________ loop.
nested
In a nested loop, the inner loop goes through all of its iterations for every iteration of the ________ loop.
outer
A(n) ________ structure is commonly known as a loop.
repetition
Which of the following is the structure that causes a statement or set of statements to execute repeatedly?
repetition
A loop that accumulates a total as it reads each number from a series is often said to keep a(n) ________.
running total
A(n) ________ represents a special value that marks the end of a list of values.
sentinel
When processing a long list of values in a loop, the program knows it has reached the end of the list when the ________ value is read.
sentinel
The amount by which the counter variable is incremented or decremented in a For loop is known as the ________.
step amount
In the following pseudocode, which value is the accumulator? Set x = 0 For m = 1 To 10 Set x = x + m End For Display x
x