Programming Logic and Design
Chapter 4 Review Questions and
Answers
Which of the following is a definite loop?
a. A loop that executes as long as a user continues to enter valid data
b. A loop that executes 1000 times
c. Both of the above
d. None of the above - ANSWER-b. A loop that executes 1000 times
Which of the following is an indefinite loop?
a. A loop that executes 10 times
b. A loop that follows a prompt that asks a user how many repetitions to make and
uses that value to control the loop
c. Both of the above
d. None of the above - ANSWER-d. None of the above
When you decrement a variable, you ______
a. Set it to 0
b. Reduce it by one tenth
c. Subtract 1 from it
d. Remove it from a program - ANSWER-c. Subtract 1 from it
When two loops are nested, the loop that is contained by the other is the ______
loop
a. Captive
b. Unstructured
c. Inner
d. Outer - ANSWER-c. Inner
When loops are nested, ______
a. The typically share a loop control variable
b. One must end before the other begins
c. Both must be the same type--definite or indefinite
d. None of the above - ANSWER-d. None of the above
The chief advantage to using a for loop is
a. Infinite loops are prevented
b. Unlike a while loop, a for can be nested
Chapter 4 Review Questions and
Answers
Which of the following is a definite loop?
a. A loop that executes as long as a user continues to enter valid data
b. A loop that executes 1000 times
c. Both of the above
d. None of the above - ANSWER-b. A loop that executes 1000 times
Which of the following is an indefinite loop?
a. A loop that executes 10 times
b. A loop that follows a prompt that asks a user how many repetitions to make and
uses that value to control the loop
c. Both of the above
d. None of the above - ANSWER-d. None of the above
When you decrement a variable, you ______
a. Set it to 0
b. Reduce it by one tenth
c. Subtract 1 from it
d. Remove it from a program - ANSWER-c. Subtract 1 from it
When two loops are nested, the loop that is contained by the other is the ______
loop
a. Captive
b. Unstructured
c. Inner
d. Outer - ANSWER-c. Inner
When loops are nested, ______
a. The typically share a loop control variable
b. One must end before the other begins
c. Both must be the same type--definite or indefinite
d. None of the above - ANSWER-d. None of the above
The chief advantage to using a for loop is
a. Infinite loops are prevented
b. Unlike a while loop, a for can be nested