Name:     ID: 
 
Email: 

ch7 review

True/False
Indicate whether the statement is true or false.
 

 1. 

The repetition structure is used to repeatedly process one or more program instructions until some condition is met, at which time the structure ends.
 

 2. 

You should not nest repetition structures.
 

 3. 

The difference between pretest and posttest loops is that in posttest loops the condition is not evaluated with each iteration of the loop, whereas in pretest loops it is.
 

 4. 

Depending on the result of the evaluation, the instructions in a posttest loop may never be processed.
 

 5. 

Of the two types of loops, the posttest loop is the most commonly used.
 

 6. 

Not every problem requires a loop in its solution.
 

 7. 

With very rare exceptions, every loop has a loop condition and a loop body.
 

 8. 

A loop condition must result in either a true or false answer only.
 

 9. 

Values used to end loops are sometimes called trip values.
 

 10. 

All loops require the user to enter a special value to end the loop.
 

 11. 

In a loop, the sentinel value should be one that is easily distinguishable from the valid data recognized by the program.
 

 12. 

In a pretest loop, when the loop condition evaluates to false, the loop body is processed; otherwise, the loop body instructions are skipped over.
 

 13. 

In flowcharts, the parallelogram is the selection/repetition symbol.
 

 14. 

In a repetition structure, when the loop condition evaluates to false, the computer skips over the loop instructions and processing continues with the instruction immediately following the end of the loop.
 

 15. 

When coding the while statement, some C++ programmers include the braces even when the loop body contains only one statement.
 

 16. 

The loop condition of the while statement cannot contain arithmetic operators.
 

 17. 

It is a good programming practice to use a comment, such as //end while, to mark the end of the while statement.
 

 18. 

A loop that processes its instructions indefinitely is referred to as an infinite loop.
 

 19. 

An accumulator is always incremented by a constant value, whereas a counter is incremented by a value that varies.
 

 20. 

You cannot use a pretest loop to create a counter-controlled loop.
 

 21. 

The while statement provides a more compact way of writing a counter-controlled loop than the for statement.
 

 22. 

The second argument in the for clause usually contains an expression that updates the counter variable specified in the initialization argument.
 

 23. 

In the for statement, if the loop body contains more than one statement, the statements must be entered as a statement block.
 

 24. 

In C++, x++ is equivalent to x = x + 2;
 

 25. 

If you omit the loop condition argument in the for clause, you need to include the break statement in the loop body to stop the loop.
 

Multiple Choice
Identify the choice that best completes the statement or answers the question.
 

 26. 

Pretest loops are also called ____ loops.
a.
top-driven
c.
primary
b.
bottom-driven
d.
secondary
 

 27. 

The repetition structure is referred to more simply as a ____.
a.
multi-path
c.
loop
b.
case
d.
switch
 

 28. 

Posttest loops are also called ____ loops.
a.
top-driven
c.
primary
b.
bottom-driven
d.
secondary
 

 29. 

In a ____ loop, the evaluation occurs after the instructions within the loop are processed.
a.
for
c.
posttest
b.
pretest
d.
while
 

 30. 

The instructions in a ____ loop will be processed at least once.
a.
for
c.
pretest
b.
while
d.
posttest
 

 31. 

The instructions within a loop are referred to as the loop ____.
a.
statement
c.
block
b.
body
d.
iterator
 

 32. 

Values that are used to end loops are referred to as ____ values.
a.
iterator
c.
break
b.
sentinel
d.
accumulator
 

 33. 

After each processing of the loop body instructions, the loop ____ is reevaluated to determine whether the instructions should be processed again.
a.
condition
c.
iterator
b.
body
d.
sentinel
 

 34. 

In a loop, the ____ read is used to prepare or set up the loop.
a.
sentinel
c.
priming
b.
accumulator
d.
initialization
 

 35. 

In a flowchart, the repetition symbol contains the loop ____.
a.
condition
c.
iterator
b.
body
d.
sentinel
 

 36. 

In a flowchart, the repetition symbol has ____ flowline(s) leading into the symbol.
a.
one
c.
three
b.
two
d.
many
 

 37. 

You can code the pretest loop in C++ using the ____ statement.
a.
repeat
c.
for
b.
switch
d.
do while
 

 38. 

When coding the while statement in C++, the loop condition must be a(n) ____ expression.
a.
arithmetic
c.
logical
b.
relational
d.
Boolean
 

 39. 

You create a statement block by enclosing the statements in a set of ____.
a.
()
c.
{}
b.
[]
d.
<>
 

 40. 

A loop that processes its instructions indefinitely is referred to as a(n) ____ loop.
a.
endless
c.
accumulating
b.
non-sentinel
d.
incorrect
 

 41. 

Usually, you can stop a program that contains an infinite loop by pressing ____.
a.
Ctrl+e
c.
Ctrl+s
b.
Ctrl+c
d.
Ctrl+x
 

 42. 

A(n) ____ is a numeric variable used for counting something, such as the number of employees paid in a week.
a.
sentinel
c.
counter
b.
iterator
d.
accumulator
 

 43. 

A(n) ____ is a numeric variable used for adding together something, such as the total dollar amount of a week’s payroll.
a.
sentinel
c.
counter
b.
iterator
d.
accumulator
 

 44. 

____ means to assign a beginning value to a counter or accumulator variable.
a.
Initializing
c.
Flushing
b.
Iterating
d.
Accumulating
 

 45. 

Updating, also called ____, means adding a number to the value stored in the counter or the accumulator.
a.
incrementing
c.
flushing
b.
iterating
d.
accumulating
 

 46. 

The most common use for the for statement is to code pretest loops whose processing is controlled by a(n) ____.
a.
flag
c.
accumulator
b.
counter
d.
sentinel
 

 47. 

The for statement begins with the for clause, which contains ____ arguments separated by semicolons.
a.
two
c.
four
b.
three
d.
many
 

 48. 

In most for clauses, the ____ argument creates and initializes a counter variable.
a.
first
c.
third
b.
second
d.
last
 

 49. 

In a for clause, the ____ argument specifies the condition that must be true for the loop to continue processing the loop body instructions.
a.
first
c.
third
b.
second
d.
last
 

 50. 

A common error made by C++ programmers is to separate the arguments in the for clause with ____.
a.
colons
c.
commas
b.
semicolons
d.
dashes
 



 
         Start Over