CMSY 141 - Chapter 5

Ace your homework & exams now with Quizwiz!

This means to increase a value

increment

These are operators that add and subtract one from their operands.

++ --

A while loop is somewhat limited because the counter can only be incremented by one each time through the loop.

False

The condition that is tested by a while loop must be enclosed in parentheses and terminated with a semicolon.

False

You may nest while and do-while loops but you may not nest for loops.

False

You may not use both break and continue statements within the same set of nested loops.

False

string objects have a member function named c_str that returns the contents of the object formatted as a null-terminated C-string.

True

The statements in the body of a while loop may never be executed while the statements in the body of a do-while loop will be executed

at least once

A statement that may be used to stop a loop's current iteration and begin the next one is

continue

A variable that is regularly incremented or decremented each time a loop iterates is a

counter

The ________ loop is ideal in situations where you want the loop to iterate at least once.

do-while

If you want a user to enter exactly 20 values, which loop would be the best to use?

for

The ________ loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop.

for

If you place a semicolon after the test expression in a while loop, it is assumed to be a(n)

null statement

The do-while loop is considered

posttest

This operator increments the value of its operand and then uses the value in context.

prefix

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

update

You may define a ________ in the initialization expression of a for loop

variable

The ________ loop is a good choice when you do not want the loop to iterate if the condition is FALSE in the beginning

while

The increment and decrement operators can be used in mathematical expressions; however, they cannot be used in relational expressions.

False

The scope of a variable declared in a for loop's initialization expression always extends beyond the body of the loop

False

You may not use the break statement in a nested loop.

False

A while loop's body can contain multiple statements, as long as they are enclosed in braces.

True

An initialization expression may be omitted from the for loop if no initialization is required.

True

An output file is a file that data is written to.

True

If you want to stop a loop before it goes through all of its iterations, the break statement may be used.

True

In C++ 11 you can pass a string object as an argument to a file stream object's open member function.

True

It is possible to define a file stream object and open a file in one statement.

True

Multiple relational expressions cannot be placed into the test condition of a for loop.

True

A statement that causes a loop to terminate early is

break

Something within a while loop must eventually cause the condition to become false or a(n) ________ results.

infinite loop

In a for statement, this expression is executed only once

initialization

This is a control structure that causes a statement or group of statements to repeat.

loop

When the increment operator precedes its operand, as ++num, the expression is in ________ mode.

prefix

The while loop is a ________ loop.

pretest

A special value that marks the end of a list of values is a

sentinel


Related study sets

AMSCO The Judicial Branch Chapter 6

View Set

Exam 2 - Chapter 9 Stocks and their Valuation

View Set

Mastering A&P Respiratory System

View Set