Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Computer Science, Looping Quiz Question 1 (1 point) int x = 0; while (x < 10) {

ID: 3558920 • Letter: C

Question

Computer Science, Looping

Quiz

Question 1 (1 point)

int x = 0;
while (x < 10) {
++x;
cout << x;
}

What is the last thing printed by the above code?

Question 1 options:

8

9

10

11

Nothing is printed

The code never ends

Save

Question 2 (1 point)

int x;

for (x = 0;x > 10;x++) {
}
cout << x;



What is the last thing printed by the above code?

Question 2 options:

0

1

2

8

9

10

11

Nothing is printed

The code never ends

Save

Question 3 (1 point)

int x;

for (x = 0; x < 10; x+=2) {

cout << x;
}

What is the output of the above code?

Question 3 options:

0 1 2 3 4 5 6 7 8 9

0 1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8 9 10

0 2 4 6 8

0 2 4 6 8 10

0 2 4 6 8 10 12

2 4 6 8

2 4 6 8 10

2 4 6 8 10 12

1 3 5 7 9

1 3 5 7 9 11

Nothing is printed

The code never ends

Save

Question 4 (1 point)

The break statement causes all loops to exit.

Question 4 options:

Save

Question 5 (1 point)

int x;

for (x = 0; x < 10; ++x) {

++x;
cout << x;
}

What is the first thing printed by the above code?

Question 5 options:

-1

0

1

2

Nothing is printed

Save

Question 6 (1 point)

How many times is "Hi" printed to the screen
for(int i=0; i<14; i++);
cout << "Hi";

Question 6 options:

14

13

15

1

Save

Question 7 (1 point)

int x;

for (int x = 0; x < 10; ++x) {

cout << x;
}

What is the last thing printed by the above code?

Question 7 options:

8

9

10

11

Nothing is printed

The code never ends

Save

Question 8 (1 point)

A compound statement that contains variable declarations is called a __________.

Save

Question 9 (1 point)

int x;

for(x = 0;x > 10;x++) {

x++;
cout << x;
}

What is the last thing printed by the above code?

Question 9 options:

8

9

10

11

Nothing is printed

The code never ends

Save

Question 10 (1 point)

int x = 0;while (x >= 0) { cout << x; x++;} What is the last thing printed by the above code?

Question 10 options:

8

9

10

11

The code does not compile.

The loop is an 'infinite loop'.

Save

Question 11 (1 point)

Each repetition of a loop body is called a(n) ____________.

Save

Question 12 (1 point)

Save

Question 13 (1 point)

What is the value of x after the following code executes?
int x=10;
if( x++ > 10 ) {
x = 13;
}

Question 13 options:

10

9

13

11

Save

Question 14 (1 point)

Complete the following code segment


// count from 1 to 100


// 1 is the first number printed
// 100 is the last number printed
int i=0;
while (i<100) {
cout << ____;
}

Save

Question 15 (1 point)

Given the following code, what is the final value of i?
int i;
for(i=0; i<=4;i++) {
cout << i << endl;
}

Question 15 options:

3

4

5

0

Save

Question 16 (1 point)

int x = 0;
while (x > 10) {
cout << x;
x++;
}

What is the last thing printed by the above code?

Question 16 options:

8

9

10

11

Nothing is printed

The code never ends

Save

Question 17 (1 point)

int x;

for (x = 0; x < 10; ++x) {

}
cout << x;



What is the last thing printed by the above code?

Question 17 options:

0

1

2

8

9

10

11

Nothing is printed

The code never ends

Save

Question 18 (1 point)

When testing a program with a loop, which of the following tests should be done?

Question 18 options:

no iterations of the loops

one less than the maximum number of iterations

the maximum number of iterations

one more than the maximum number of iterations

A and B

A, B and C

Save

Question 19 (1 point)

int x = 0;
while (x < 10) {
cout << x;
x+=2;
}

What is the output of the above code?

Question 19 options:

0 1 2 3 4 5 6 7 8 9

0 1 2 3 4 5 6 7 8 9 10

1 2 3 4 5 6 7 8 9

1 2 3 4 5 6 7 8 9 10

0 2 4 6 8

0 2 4 6 8 10

0 2 4 6 8 10 12

2 4 6 8

2 4 6 8 10

2 4 6 8 10 12

1 3 5 7 9

1 3 5 7 9 11

Nothing is printed

The code never ends

Save

Question 20 (1 point)

int x = 0;
while (x > 10) {
cout << x;
x++;
}

What is the first thing printed by the above code?

Question 20 options:

-1

0

1

2

Nothing is printed

Note: It is recommended that you save your response as you complete each question.

Explanation / Answer

1) 9

loop repeats from 0 to 9, for 10 times

2) 0

for loop assigns 0 to x

3) 0 2 4 6 8

4) false

exits the nearest loop but not all loops

5) 1

1 3 5 7 9 is the output

'6) 1

since there is a ';', thought the loop repeats 14 times, there is no relation between the loop and cout statement

7) 9

8) block

9)nothing is printed

10)the loop is an infinite loop

11) iteration

12) i

also incrementi: i++;

13) 11

14) i+1;

alse increment i by 1

15) 4

16) nothing is printed

17) 0

18) A, B and C

19) 0 2 4 6 8

20) nothing is printed

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote