Teacher Name:Mr. Rung Date of Lesson: December
Course Name: C++ Lesson Name: Chap 8.1b
Student Name
Password
Objective To complete the workbook exercises.
Primary Focus Please answer the questions below.
Site Links Course Home Page
Additional Resources
Site Links
Question #1
How many times will the following for loop repeat? for (i = 1; i < = 5, i++)
A: 1 B: 5 C: 4 D: 6 E: None of these
Question #2
How many times will the following for loop repeat? for (i = 2; i < = 5; i++)
Question #3
How many times will the following for loop repeat? for (i = 2; i < 5; i++)
Question #4
What is the count progression of the variable I in the following for statement? for (i = 3; i < 12 ; i = i + 2)
A: 3 B: 3 5 7 9 11 13 C: 1 3 5 7 9 11 D: 3 5 7 9 11 E: None of these
Question #5
What is the value of j in each iteration of the following loop? int i,j; for (i = 10; i <= lOO; i = i + 10) j = i / 2;
A: 5 10 15 20 25 30 35 40 45 50 B: 10 20 30 40 50 60 70 80 90 100 C: 5 10 15 20 25 30 35 40 45 50 55 D: 10 20 30 40 50 60 70 80 90 E: None of these
Question #6
How many times will a loop controlled by the following statement iterate? for (j = 5; j<=20; j = j + 5)
Question #7
What is the value of r after the following statements have executed? int r,j; for (j = 1; j < 10; j =j*2); r = 2*j;
A: 16 B: 8 C: 4 D: 32 E: None of these
Question #8
Write a loop that will print the numerals 3, 6, 12,24,48, and 96.
A: for (j = 3; j = 96; j =j*2); B: for (j = 0; j <= 96; j =j*2); C: for (j = 3; j < 96; j =j*2); D: for (j = 3; j <= 96; j =j*2); E: None of these
Question #9
Write a loop that will print the numerals 96,48, 24, 12, 6, and 3.
A: for (j = 96; j >= 0; j =j/2); B: for (j = 96; j > 3; j =j/2); C: for (j = 96; j >= 3; j =j/2); D: for (j = 96; j >= 3; j =j*2); E: None of these
Question #10
Write a ioop that will print the numerals 256,128, 64, 32, 16, 8, 4, 2 and 1.
A: for (j = 1; j >= 256; j =j/2); B: for (j = 256; j >= 1; j =j/2); C: for (j = 256; j > 1; j =j/2); D: for (j = 256; j >= 1; j =j*2); E: None of these