Uploaded by Reuben Afriyie

Chapter 5 Study Guide Flashcards Quizlet

advertisement
Home
Explanations
Your library
Create
Free
trial
Chapter 5 Study Guide
Terms in this set (40)
1) ________ are C++ operators that
++ and --
change their operands by one.
2) True/False: To decrement a
False
number means to increase its
value.
3) The ++ operator
4) What will the following code
All of the above.
None of these
print?
5) The while loop has two
repeated as long as the condition is true.
important parts: a condition
that is tested and a statement
or block of statements that is
6) True/False: The block of
code in the body of a while
statement can contain an
unlimited number of
statements, provided they are
enclosed in a set of braces.
Chapter 5 Study Guide
True
S...
True/False: A while loop may
False
have a semicolon after the test
expression and before the
body of the loop, but it is not
required.
8) True/False: A while loop is
False
somewhat limited, because the
counter can only count up, not
down.
9) The while loop is a(n) ________
pretest, post-test
loop, whereas the do-while
loop is a(n) ________ loop.
10) The statements in the body
at least once
of a do-while loop are
executed
11) A sentinel is a special value
marks the end of a list of values.
that
12) A for statement contains
update
three expressions: initialization,
test, and
13) In a for statement, the ________
expression is executed only
once.
Chapter 5 Study Guide
initialization
14) True/False: An initialization
True
expression may be omitted
from the for loop if no
initialization is required.
15) You may define a(n) ________ in
variable
the initialization expression of a
for loop.
16) When a loop is nested
False
inside another loop, the outer
loop goes through all its
iterations for each iteration of
the inner loop.
17) A variable that keeps a
accumulator
running total of data values is
called a(n)
18) For data validation, it is best
while
to use a(n)
19) To use files in a C++ program
fstream
you must include the ________
header file.
20) To use an output file in a
E) do B and C, but not A.
C++ program you must
1) To ________ a value means to
increment
increase it.
2) The -- operator
Chapter 5 Study Guide
All of the above are true.
3) What will the following code
565
print?
num = 5;
cout << num++ << " ";
cout << num-- << " ";
cout << --num;
4) The while loop has two
As long as the condition is true
important parts: a condition
that is tested and a statement
or block of statements that is
executed
5) If nothing within a while loop
infinite loop
ever causes the condition to
become false, a(n) ________ may
occur.
6) True/False: A while loop is
True
somewhat limited because the
counter can only be
incremented or decremented
by one each time through the
loop.
7) A(n) ________ is a variable that
loop control variable
controls the number of times a
loop iterates.
8) A(n) ________ is a variable that
is regularly incremented or
decremented each time a loop
iterates.
Chapter 5 Study Guide
counter
9) True/False: When a loop is
true
nested inside another loop, the
inner loop goes through all its
iterations for each iteration of
the outer loop.
10) A(n) ________ is a special value
sentinel
that marks the end of a list of
values.
11) The do-while loop is a(n)
post test, pretest
________ loop, whereas the while
loop is a(n) ________ loop.
12) True/False: You can nest a
False
for loop inside another for
loop, but cannot nest a while
loop inside another while loop
or a do-while loop inside
another do-while loop.
13) The statements in the body
at least once.
of a do-while loop are
executed
14) True/False: Before
False
beginning to add value to it, an
accumulator should be
initialized to 1.
15) The ________ statement causes
a loop to terminate early.
Chapter 5 Study Guide
break
16) If a while loop has no
the loop body contains just one statement
braces around the body of the
loop
17) The ideal type of loop to
for
use if you want a user to enter
exactly 20 values is a(n) ________
loop.
18) The ideal type of loop to
do-while
use for repeating a menu is a(n)
________ loop.
19) To use files in a C++ program
fstream
you must include the ________
header file.
20) In order for a C++ program
to read data from a file,
All of the above are required.
Download