quiz 5 review
What is the output of the following code segment? n = 1; while (n <= 5) cout << n << ' '; n++;
1 forever
How many times will the following loop display "Hello"? for (int i = 0; i <= 20; i++) cout << "Hello!" << endl;
21
int x = 0; for (int count = 0; count < 3; count++) x += count; cout << x << endl;
3
What will the following code display? int number = 6 int x = 0; x = --number; cout << x << endl;
5
What will the following code display? int number = 6; int x = 0; x = number--; cout << x << endl;
6
To write data to a file, you define an object of this data type.
ofstream
Assuming outFile is a file stream object and number is a variable, which statement writes the contents of number to the file associated with outFile?
outFile << number;
The do-while loop is a(n) ________ loop that is ideal in situations where you always want the loop to iterate at least once.
post test
The do-while loop is considered a(n) ________ loop.
post test
A for statement contains three expressions: initialization, test, and
update
This is a pre-test loop that is ideal in situations where you do not want the loop to iterate if the condition is false from the beginning.
while