Quiz 2 Flashcards
Which of the following statements is not a repetition structure?
1. while
2. for
3. do while
4. if - else if - else
if - else if - else
Loops may be “nested” inside of other loops. True or false?
True.
In the following for loop, what is the bolded section of the loop known as?
for(
int i = 0;
i < 10; i++){
// do stuff
}
initialization statement
remember, it’s initializing the variable i
The for
loop is a post-test loop. True or false?
False. It is a pre-test loop
The while
loop is a pretest loop. True or false?
True.
A while loop is ideal for performing \_\_\_\_\_\_\_\_\_\_\_\_\_\_
iterations?
1. a fixed number
2. 0 or more
3. 1 or more
- 0 or more
The for
loop is best described as which of the following?
1. a post-test loop
2. a condition-controlled loop
3. a while loop
4. a count-controlled loop
a count-controlled loop
Which loop is a post-test loop?
The do while
loop
In C++ the Boolean value false
is stored in memory as the numeric value 1
. True or false?
False. It is stored as 0
.
Assume the following, x = 8
, y = 10
, and z = 12
. What is the result of the Boolean Expression: x != 8 || x <= y
?
True
In C++, when characters are compared (char
datatype) the integer ASCII values are used. True or false?
True.
You should always close a file when you are done with it. True or false?
True.
In the following for loop, what is the bolded section of the loop known as?
for(int i = 0; i < 10;
i++){
// do stuff
}
update statement
If you try to open a file to read from it, and the file does not exist, the program will fail to compile. True or false?
False
When you call an ofstream
object’s open function, the file will be erased if it already exists. True or false?
True.