C++ Chapter 5

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

________ are C++ operators that change their operands by one.

++ and --

What will the following code print? num = 8; cout << --num << " "; cout << num++ << " "; cout << num;

7 7 8

In order for a C++ program to read data from a file,

All of the above are required. the program must open the file. the file must already exist. the program must define a file stream object that can "point to" (i.e., reference) the file.

The ++ operator

All of the above; is a unary operator. can operate in prefix or postfix mode. adds one to the value of its operand.

A variable that keeps a running total of data values is called a(n)

accumulator.

The statements in the body of a do-while loop are executed

at least once.

The ________ statement causes a loop to terminate early.

break

A(n) ________ is a variable that is regularly incremented or decremented each time a loop iterates.

counter

The ideal type of loop to use for repeating a menu is a(n) ________ loop.

do-while

The ideal type of loop to use if you want a user to enter exactly 20 values is a(n) ________ loop.

for

To use files in a C++ program you must include the ________ header file.

fstream

To ________ a value means to increase it.

increment

In a for statement, the ________ expression is executed only once.

initialization

A sentinel is a special value that

marks the end of a list of values.

The while loop is a(n) ________ loop, whereas the do-while loop is a(n) ________ loop.

pretest, posttest

The while loop has two important parts: a condition that is tested and a statement or block of statements that is

repeated as long as the condition is true.

If a while loop has no braces around the body of the loop

the loop body contains just one statement.

A for statement contains three expressions: initialization, test, and

update.

You may define a(n) ________ in the initialization expression of a for loop.

variable

For data validation, it is best to use a(n)

while loop.


Ensembles d'études connexes

Unit 8/9/Midterm Multiple Choice

View Set

Chapter 2 - Real Property - Mini Quiz

View Set

Psychiatric/Mental Health Review

View Set