Exam 5: Loops and Files

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

The do-while loop is a __________ loop that is ideal in situations where you always want the loop to iterate at least once.

Free
(Multiple Choice)
4.8/5
(36)
Correct Answer:
Verified

A

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

Free
(Multiple Choice)
4.9/5
(41)
Correct Answer:
Verified

B

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

Free
(Multiple Choice)
4.8/5
(40)
Correct Answer:
Verified

C

What will the following code display? int x = 0; For (int count = 0; count < 3; count++) \quad x += count; cout << x << endl;

(Multiple Choice)
4.9/5
(39)

This statement causes a loop to terminate early.

(Multiple Choice)
4.9/5
(30)

How many times will the following loop display "Hello"? for (int i = 0; i <= 20; i++) \quad cout << "Hello!" << endl;

(Multiple Choice)
4.9/5
(36)

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

(True/False)
4.8/5
(40)

What will the following loop display? int x = 0; while (x < 5) { \quad cout << x << endl; \quad x++; }

(Multiple Choice)
4.8/5
(43)

How many times will the following loop display "Hello"? for (int i = 0; i < 20; i++) \quad cout << "Hello!" << endl;

(Multiple Choice)
5.0/5
(50)

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

(Multiple Choice)
4.8/5
(36)

To read data from a file, you define an object of this data type.

(Multiple Choice)
4.8/5
(37)

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

(True/False)
4.8/5
(43)

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

(Multiple Choice)
4.9/5
(39)

To write data to a file, you define an object of this data type.

(Multiple Choice)
5.0/5
(35)

What will the following code display? int number = 6; int x = 0; x = number--; cout << x << endl;

(Multiple Choice)
4.9/5
(29)

This statement may be used to stop a loop's current iteration and begin the next one.

(Multiple Choice)
4.8/5
(41)

In a for statement, this expression is executed only once.

(Multiple Choice)
4.8/5
(30)

The do-while loop is considered a(n) _________ loop.

(Multiple Choice)
4.8/5
(36)

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

(True/False)
4.8/5
(42)

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

(Multiple Choice)
4.9/5
(34)
Showing 1 - 20 of 62
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)