Question 1.1. (TCO 5) Which structure causes a statement or set of statements to execute repeatedly?
Decision
Repetition
Sequence
None of the above
Question 2.2. (TCO 5) Which repetition structure is designed to have the code execute at least one time?
For loop
Do in a while loop
While loop
Do-while loop
Question 3.3. (TCO 10) An error that results from a poorly planned solution would be called a _____.
syntax error
logical error
typing error
debugging error
Question 4.4. (TCO 5) Which of the following is true about the for loop?
It is a pretest loop.
It needs a loop index which counts the number of loop iterations as the loop executes.
It can be used when you do know the number of times you want the loop body to execute.
All of the above.
Question 5.5. (TCO 5) A loop that is inside another loop is called an _____.
outer loop
inner loop
infinite loop
None of the above
Question 6.6. (TCO 5) What syntax error is in the following code?
int i = 0;
do
{
cout << "I is " << i << endl;
i++;
} while (i < 10)
Nothing is incorrect about the code.
Missing a semicolon after the word "do"
Missing a semicolon after the "while (I < 10)"
Cannot be determined
Question 7.7. (TCO 5) The most difficult aspect of working with _____ loops is keeping track of the separate loop control variables that direct the program's execution.
nested
controlled-counter
outer
counter-controlled
Question 8.8. (TCO 5) How many times will this for loop execute?
for (int i = 100; i > 0; --i)
Zero - the loop will not execute
99
100
The loop is not written correctly. It would not compile.
Question 9.9. (TCO 5) The segment of code shown below displays "Hello!" _____ times.
int count;
const int NUM_LOOPS = 5;
count = 0;
while( count <= NUM_LOOPS)
{
cout<< "Hello!" <++count;
}
zero
four
five
six
Question 10.10. (TCO 5) Consider the execution of the following for loop. If the last value printed is 5, which of the following might have been used for increment?
for (int x = 1; x < 5; increment )
cout << x + 1 << endl;
++x
x++
x+=1
x=x+1
Any of the above would work.
Question 11. 11. (TCO 5) Using a loop, write a program that reads in exactly five integers and outputs the sum.