Filters
Question type

Study Flashcards

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


A) while
B) for
C) switch
D) do-while
E) None of these

Correct Answer

verifed

verified

How many times will the following loop display "Looping!"? For (int i = 20; i > 0; i--) Cout << "Looping!" << endl;


A) 20
B) 19
C) 21
D) an infinite number of times

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

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


A) decision statement
B) loop
C) cout object
D) selection structure
E) None of these

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

To write information to a file, use the


A) cout object
B) pen object
C) output object
D) stream insertion operator
E) None of these

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

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


A) null value
B) infinite loop
C) unexpected exit
D) compiler error
E) None of these

Correct Answer

verifed

verified

You may define a __________ in the initialization expression of a for loop.


A) constant
B) function
C) variable
D) new data type
E) None of these

Correct Answer

verifed

verified

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


A) at least once
B) at least twice
C) never
D) as many times as the user wishes
E) None of these

Correct Answer

verifed

verified

What will the following code display? int number = 6; ++number; cout << number << endl;


A) 6
B) 5
C) 7
D) 0

Correct Answer

verifed

verified

To write read data from a file, you define an object of the __________ data type.


A) inputFile
B) ifstream
C) fstream
D) ofstream

Correct Answer

verifed

verified

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

Correct Answer

verifed

verified

What will the following code display? Int number = 6; Cout << ++number << endl;


A) 6
B) 5
C) 7
D) 0

Correct Answer

verifed

verified

What will the following code display? Int number = 6; Cout << number++ << endl;


A) 6
B) 5
C) 7
D) 0

Correct Answer

verifed

verified

Assuming dataFile is a file stream object, the following statement: DataFile.close() ;


A) is illegal in C++
B) needs a filename argument to execute correctly
C) closes a file
D) is legal but risks losing valuable data
E) None of these

Correct Answer

verifed

verified

A loop that is inside another loop is called a(n)


A) infinite loop
B) pre-test loop
C) post-test loop
D) nested loop
E) None of these

Correct Answer

verifed

verified

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


A) update
B) reversal
C) null
D) validation
E) None of these

Correct Answer

verifed

verified

In the following statement, which operator is used first? While (x++ < 10)


A) ++
B) <
C) neither; the expression is invalid
D) cannot tell without the rest of the code

Correct Answer

verifed

verified

Showing 41 - 60 of 60

Related Exams

Show Answer