0% found this document useful (0 votes)
40 views2 pages

Chapter 4

This document contains review questions about programming concepts related to repetition structures such as loops. It includes multiple choice, true/false, and short answer questions testing understanding of condition-controlled loops, count-controlled loops, loop iterations, accumulator variables, nested loops, sentinels, input validation, and the phrase "garbage in, garbage out".

Uploaded by

apap.004589
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views2 pages

Chapter 4

This document contains review questions about programming concepts related to repetition structures such as loops. It includes multiple choice, true/false, and short answer questions testing understanding of condition-controlled loops, count-controlled loops, loop iterations, accumulator variables, nested loops, sentinels, input validation, and the phrase "garbage in, garbage out".

Uploaded by

apap.004589
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Review Questions 223

Review Questions
Multiple Choice
1. A __________ -controlled loop uses a true/false condition to control the number of
times that it repeats.
a. Boolean
b. condition
c. decision
d. count
2. A __________ -controlled loop repeats a specific number of times.
a. Boolean
b. condition
c. decision
d. count
3. Each repetition of a loop is known as a(n) __________.
a. cycle
b. revolution
c. orbit
d. iteration
4. The while loop is a __________ type of loop.
a. pretest
b. no-test
c. prequalified
d. post-iterative
5. A(n) __________ loop has no way of ending and repeats until the program is inter-
rupted.
a. indeterminate
b. interminable
c. infinite
d. timeless
6. The -= operator is an example of a(n) __________ operator.
a. relational
b. augmented assignment
c. complex assignment
d. reverse assignment
7. A(n) __________ variable keeps a running total.
a. sentinel
b. sum
c. total
d. accumulator
8. 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.
a. sentinel
b. flag
c. signal
d. accumulator
224 Chapter 4 Repetition Structures

9. GIGO stands for .


a. great input, great output
b. garbage in, garbage out
c. GIGahertz Output
d. GIGabyte Operation
10. The integrity of a program’s output is only as good as the integrity of the program’s
.
a. compiler
b. programming language
c. input
d. debugger
11. The input operation that appears just before a validation loop is known as the .
a. prevalidation read
b. primordial read
c. initialization read
d. priming read
12. Validation loops are also known as .
a. error traps
b. doomsday loops
c. error avoidance loops
d. defensive loops
True or False
1. A condition-controlled loop always repeats a specific number of times. False
2. The while loop is a pretest loop. True
3. The following statement subtracts 1 from x: x = x − 1 True
4. It is not necessary to initialize accumulator variables. False
5. In a nested loop, the inner loop goes through all of its iterations for every single itera-
tion of the outer loop.True
6. To calculate the total number of iterations of a nested loop, add the number of itera-
tions of all the loops. False
7. The process of input validation works as follows: when the user of a program enters
invalid data, the program should ask the user “Are you sure you meant to enter that?”
If the user answers “yes,” the program should accept the data. False
Short Answer
1. What is a condition-controlled loop?
2. What is a count-controlled loop?
3. What is an infinite loop? Write the code for an infinite loop.
4. How are an accumulator variable and a loop used to calculate a running total?
5. How many iterations would occur in total if a loop that repeats 5 times is nested
seemed
within a loop that repeats 4 times?
6. Why must the value chosen for use as a sentinel be carefully selected?
7. What does the phrase “garbage in, garbage out” mean?
8. Give a general description of the input validation process.

You might also like