Quiz 6, Chapter 5

25 July 2022
4.7 (114 reviews)
20 test answers

Unlock all answers in this set

Unlock answers (16)
question
Which of the following is a repetition structure in C++?
answer
do...while
question
Which of the following loops does not have an entry condition?
answer
do...while loop
question
Which of the following loops is guaranteed to execute at least once?
answer
do...while loop
question
Which of the following statements generates a random number between 0 and 50?
answer
srand(time(0)); num = rand() % 50;
question
____ loops are called posttest loops.
answer
do...while
question
Assume that all variables are properly declared. The following for loop executes 20 times. for (i = 0; i <= 20; i++) cout << i;
answer
False
question
In a counter-controlled while loop, the loop control variable must be initialized before the loop.
answer
True
question
In a sentinel-controlled while loop, the body of the loop continues to execute until the EOF symbol is read.
answer
False
question
In the case of the sentinel-controlled while loop, the first item is read before the while loop is entered.
answer
True
question
The control statements in the for loop include the initial statement, loop condition, and update statement.
answer
True
question
The control variable in a flag-controlled while loop is a bool variable.
answer
True
question
The following while loop terminates when j > 20. j = 0; while (j < 20)
answer
False
question
The number of iterations of a counter-controlled loop is known in advance.
answer
True
question
The statement in the body of a while loop acts as a decision maker.
answer
False
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 << " "; }
answer
True
question
A do...while loop is a(n) ____________________ loop, since the loop condition is evaluated after executing the body of the loop.
answer
posttest
question
A for loop is typically called a counted or ____________________ for loop.
answer
indexed
question
A loop ____________________ is a set of statements that remains true each time the loop body is executed.
answer
invariant
question
A semicolon at the end of the for statement (just before the body of the loop) is a(n) ____________________ error.
answer
semantic
question
A software ____________________ is a piece of code written on top of an existing piece of code intended to fix a bug in the original code.
answer
patch