Chapter 5 Flashcards

Looping

1
Q

[Blank] are C++ operators the change their operands by one.

A

++ and –

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

True/False: To decrement a number means to increase its value.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The ++ operator

A

Is a unary operator, adds one the the value of its operand, and can operate in prefix or postfix mode.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What will the following code print?
num = 8;
cout &laquo_space;–num &laquo_space;” “;
cout &laquo_space;num++ &laquo_space;” “;
cout &laquo_space;num;

A

7 7 8

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

repeated as long as the condition is true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

True/False: A while loop may have a semicolon after the test expression and before the body of the loop, but it is not required.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

True/False: A while loop is somewhat limited, because the counter can only count up, not down.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The while loop is a(n) [Blank] loop, where as the do-while loop is a(n) [Blank] loop.

A

pretest, post test

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

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

A

at least once

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

A sentinel is a special value that …

A

marks the end of a list of values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

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

A

update

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

In a for statement, the [Blank] expression is executed only once.

A

initialization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

True/False: An initialization expression may be omitted from the for loop if no initialization is required.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

You may define a(n) [Blank] in the initialization expression of a for loop.

A

variable

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

True/False: When a loop is nested inside another loop the outer loop goes through all its iterations for each iteration of the inner loop.

A

False

17
Q

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

A

accumulator

18
Q

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

A

while loop

19
Q

To use files in a C++ program you must included the [Blank] header file

A

fstream

20
Q

To use an output fie in a C++ program you must …

A

create a file stream object that will “point to”(i.e. reference) the file and open the file