C++ Early Objects Ch. 5

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Accumulator

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

loop control variable

A(n) ____ is a variable that controls the number of times a loop iterates.

the ++ operator : is a unary operator. adds one to the value of its operand. can operate in prefix or postfix mode. all of these. Both adds one to the value of its operand and can operate in prefix or postfix mode, but not is a unary operator

All of these

In order for a C++ program to read data from a file, : the file must already exist. the program must define a file stream object that can "point to" (i.e., reference) the file. the program must open the file. All of these are required.

All of these are required

The ideal type of loop to use if you want a user to enter exactly 20 values is a(n)_____ loop. sentinel controlled infinite for do-while nested

for

To use files in a C++ program you must include the _____ header file. file iostream fstream both file and iostream both iostream and fstream

fstream

To _____ a value means to increase it. accumulate increment total add up decrement

increment

If nothing within a while loop ever causes the condition to become false, a(n) ____ may occur.

infinite loop

A sentinel is a special value that: is used for data validation. must be Boolean. marks the end of a list of values. must be a negative number. All of these

marks the end of a list of values

The do-while loop is a(n)____loop, whereas the while loop is a(n) _____ loop. infinite, finite pretest, posttest posttest, pretest finite, infinite simple, complex

posttest, pretest

The while loops is a(n) _____ loop, whereas the do-while loop is a(n) ____ loop

pretest, posttest

A for statement contains three expressions: initialization, test and : quit. repeat. update. validate. increment.

update

For data validation, it is best to use a(n) if statement. for loop. nested loop. while loop. switch statement.

while loop

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

5 6 4

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

7 7 8

In a for statement, the ____ expression is executed only once. update. test. validate repeat initialization

Initialization

The statements in the body of a do-while loop are executed : forever until the user presses the break key. until an exit statement is encountered at least once. only if the test condition is initially true. until the test condition becomes true.

at least once

The ____ statement causes a loop to terminate early. break continue quit stop terminate

break

The ideal type of loop to use for repeating a menu is a(n) _____ loop. infinite for sentinel controlled nested do-while

do-while

The while loop has two important parts: a condition that is tested and a statement or block of statements that is : done once if the condition is true. repeated as long as the condition is true. repeated until the condition becomes true. always skipped always done at least once, then repeated if the condition is true.

repeated as long as the condition is true

If a while loop has no braces around the body of the loop: there is no loop body. the program will compile, but not run. the loop body contains just one statement. the program will not compile. the loop body ends when the endwhile statement is encountered.

the loop body contains just one statement


Kaugnay na mga set ng pag-aaral

Linear Regression and Ordinary Least Squares

View Set

Chapter 7: Client's Response to Illness

View Set

Zoology Lab practical chpters 10-14

View Set

CISR Insuring Commerical Property

View Set

The Changing Environments of Organization Chapter 2

View Set

SOC 350 Exam 1 Key Concepts Chapter 2

View Set

Chapter 5: Adult Health and Nutritional Assessment Prep-U

View Set

Experiment 12: The Dehydration of Cyclohexanol

View Set