1. (TCO 5) In a count-controlled loop, the counter performs which of the following actions? (Points : 3)
a)Counter initialization
b)Counter testing
c)Counter adjustment
d)All of the above
2. (TCO 5) Which repetition structure is designed to have the code execute at least one time? (Points : 3)
a)For loop
b)Do in a while loop
c)While loop
d)Do-while loop
3. (TCO 10) Bug errors are _____ errors. (Points : 3)
a) logic
b)syntax
c)binary
d)asp.net
4. (TCO 5) Which of the following is true about the for loop? (Points : 3)
a) It is a posttest loop.
b)It is a pretest loop.
c)It is an infinite loop.
d)All of the above are true and correct about the for loop.
5. (TCO 5) A loop that is inside another loop is called an _____. (Points : 3)
a)outer loop
b)inner loop
c)infinite loop
d)None of the above
6. (TCO 5) Which of the following is a poor programming practice? (Points : 3)
a)Indenting the statements in the body of each control structure
b)Using floating-point values for counters in counter-controlled repetition
c)Nesting multiple repetition structures
d)Placing vertical spacing above and below control structures
7. (TCO 5) A loop that falls entirely within the body of another is a(n) ____ loop. (Points : 3)
a) outer
b)inner
c)parent
d)restricted
8. (TCO 5) How many times will this for loop execute?
for (int i = 10; i > 0; --i) (Points : 3)
a)Seven
b)Nine
c)10
d)Eight
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!" <<endl;
++count;
} (Points : 3)
a)zero
b)four
c)five
d)six
10. (TCO 5) Which of the following for loop is invalid? (Points : 3)
a)for(int i=1, j=10; i<=5; i++;j--)
b)for(int i=1; i<=5;)
{++i;}
c)for(int i=1, total=0; i<=5; i++)
int i=1;
d)for(; i<=5; ++i)
All of the above
11. (TCO 5) Using a loop, write a program that reads in exactly five integers and outputs the sum. (Points : 5)
int main()
{
int n1, n2, n3, n4, n5;
int sum = 0;
cout << "Enter five numbers: ";
cin >> n1;
cin >> n2;
cin >> n3;
cin >> n4;
cin >> n5;
sum = n1 + n2 + n3 + n4 + n5;
cout << "Sum = " << sum << endl;
return 0;
}
12 years ago
Purchase the answer to view it

- new.docx