CSC 101 Quiz 5

25 July 2022
4.7 (114 reviews)
15 test answers

Unlock all answers in this set

Unlock answers (11)
question
A loop is a control structure that allows you to repeat a set of statements until certain conditions are met. Select one: True False
answer
True
question
Loop control variables are automatically initialized in a loop. Select one: True False
answer
False
question
In a counter-controlled while loop, the loop control variable must be initialized before the loop. Select one: True False
answer
True
question
Assume all variables are properly declared. The output of the following C++ code is 2 3 4 5. n = 1; while (n < 5) { n++; cout << n << " "; } Select one: True False
answer
True
question
A sentinel-controlled while loop is an event-controlled while loop whose termination depends on a special value. Select one: True False
answer
True
question
In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered. Select one: True False
answer
True
question
In a sentinel-controlled while loop, the body of the loop continues to execute until the EOF symbol is read. Select one: True False
answer
False
question
The control variable in a flag-controlled while loop is a bool variable. Select one: True False
answer
True
question
The function eof returns true if the program has read past the end of the input file. Select one: True False
answer
True
question
It is possible that the body of a while loop may not execute at all, but the body of a for loop executes at least once. Select one: True False
answer
False
question
The execution of a break statement in a while loop terminates the loop. Select one: True False
answer
True
question
After a break statement executes, the program continues to execute with the first statement after the structure. Select one: True False
answer
True
question
A(n) ____-controlled while loop uses a bool variable to control the loop. Select one: a. counter b. sentinel c. flag d. EOF
answer
c. flag
question
Consider the following code. (Assume that all variables are properly declared.) cin >> ch; while (cin) { cout << ch; cin >> ch; } This code is an example of a(n) ____ while loop. Select one: a. sentinel-controlled b. flag-controlled c. EOF-controlled d. counter-controlled
answer
c. EOF-controlled
question
The ____ statement can be used to eliminate the use of certain bool variables in a loop. Select one: a. if b. while c. switch d. break
answer
d. break