Filters
Question type

Study Flashcards

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

A) True
B) False

Correct Answer

verifed

verified

False

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

A) True
B) False

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

False

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.
B) repeated until the condition becomes True.
C) done once if the condition is True.
D) always done at least once, then repeated if the condition is True.
E) always skipped.

F) A) and B)
G) A) and E)

Correct Answer

verifed

verified

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


A) fstream
B) iostream
C) file
D) Both A and B are needed.
E) Both B and C are needed.

F) None of the above
G) C) and D)

Correct Answer

verifed

verified

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


A) finite, infinite
B) infinite, finite
C) simple, complex
D) pretest, post test
E) post test, pretest

F) C) and D)
G) B) and D)

Correct Answer

verifed

verified

The -- operator


A) is a unary operator.
B) subtracts one from the value of its operand.
C) must have an lvalue, such as a variable, as its operand.
D) can be used in either prefix or postfix mode.
E) All of the above are True.

F) A) and E)
G) B) and E)

Correct Answer

verifed

verified

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


A) initialization
B) test
C) repeat
D) validate
E) update

F) B) and D)
G) A) and B)

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

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


A) counter
B) accumulator
C) sentinel
D) total
E) loop control variable

F) B) and E)
G) A) and E)

Correct Answer

verifed

verified

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


A) there is no loop body.
B) the loop body ends when the endwhile statement is encountered.
C) the loop body contains just one statement.
D) the program will not compile.
E) the program will compile, but not run.

F) A) and C)
G) C) and D)

Correct Answer

verifed

verified

C

To use an output file in a C++ program you must


A) make sure the file already exists.
B) create a file stream object that will "point to" (i.e. reference) the file.
C) open the file.
D) do all of the above.
E) do B and C, but not A.

F) A) and E)
G) B) and C)

Correct Answer

verifed

verified

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


A) + and -
B) ++ and --
C) binary and unary
D) arithmetic and relational
E) conditional and relational

F) All of the above
G) A) and B)

Correct Answer

verifed

verified

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


A) repeat.
B) validate.
C) update.
D) quit.
E) increment.

F) A) and B)
G) A) and C)

Correct Answer

verifed

verified

You can nest a 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.

A) True
B) False

Correct Answer

verifed

verified

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


A) file
B) iostream
C) fstream
D) Both A and B.
E) Both B and C.

F) B) and E)
G) A) and B)

Correct Answer

verifed

verified

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


A) new data type
B) new keyword
C) constant
D) variable
E) operator

F) A) and E)
G) B) and E)

Correct Answer

verifed

verified

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


A) exactly once.
B) at least once.
C) only if the test condition is initially True.
D) until the test condition becomes True.
E) forever until the user hits the break key.

F) C) and D)
G) D) and E)

Correct Answer

verifed

verified

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

A) True
B) False

Correct Answer

verifed

verified

Before beginning to add value to it, an accumulator should be initialized to 1.

A) True
B) False

Correct Answer

verifed

verified

Showing 1 - 20 of 40

Related Exams

Show Answer