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

Question 1 (1 point) int x = 0; while (x < 10) { x++; cout << x; } What is the f

ID: 3910502 • Letter: Q

Question

Question 1 (1 point)

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

What is the first thing printed by the above code?

Question 1 options:

-1

0

1

2

Nothing is printed

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 = 0;
while (x < 10) {
cout << x;
x++;
}

What is the last thing printed by the above code?

Question 3 options:

8

9

10

11

Nothing is printed

The code never ends

Save

Question 4 (1 point)

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

What is the last thing printed by the above code?

Question 4 options:

8

9

10

11

Nothing is printed

The code never ends

Save

Question 5 (1 point)

Which of the following symbols has the highest precedence?

Question 5 options:

++

||

&&

-

Save

Question 6 (1 point)

Which of the following code segments will count from 1 to 100 (including 1 and 100)?

Question 6 options:

for (int i=1; i<100; i++) {}

for (int i=1; i<100; ++i) {}

for (int i=0; i<=100; i++) {}

for (int i=0; i<=100; ++i) {}

for (int i=1; i<=100; ++i) {}

Save

Question 7 (1 point)

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

What is the first thing printed by the above code?

Question 7 options:

-1

0

1

2

Nothing is printed

Save

Question 8 (1 point)

If you need to write a do-while loop that will ask the user to enter a number between 2 and 5 inclusive, and will keep asking until the user enters a correct number, what is the loop condition?

Question 8 options:

(2<=num<=5)

(2<5

(2 <= number && number <= 5)

(2 > number || number > 5)

(2 > number && number > 5)

(2 < number || number < 5)

(2 < number && number < 5)

(2 <= number || number <= 5)

Save

Question 9 (1 point)

int x;

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

}
cout << x;



What is the last thing printed by the above code?

Question 9 options:

0

1

2

8

9

10

11

Nothing is printed

The code never ends

Save

Question 10 (1 point)

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

What is the last thing printed by the above code?

Question 10 options:

8

9

10

11

Nothing is printed

The code never ends

Save

Question 11 (1 point)

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

What is the last thing printed by the above code?

Question 11 options:

8

9

10

11

Nothing is printed

The code never ends

Save

Question 12 (1 point)

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

Question 12 options:

10

9

13

11

Save

Question 13 (1 point)

If you want a loop to quit iterating if x < 10 and y > 3, what would be the proper loop condition test?

Question 13 options:

(x < 10 && y > 3)

(x >10 || y < 3)

(x >=10 && y <=3)

(x >=10 || y <=3)

Save

Question 14 (1 point)

int x;

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

cout << x;
}

What is the output of the above code?

Question 14 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 15 (1 point)

What is wrong with the following for loop?
for(int i=0;i<10;i--) {
cout << "Hello ";
}

Question 15 options:

can not use a for-loop for this

i is not initialized

infinite loop

off-by-one error

Save

Question 16 (1 point)

Which loop structure always executes at least once?

Question 16 options:

do-while

for

while

sentinel

Save

Question 17 (1 point)

Which of the following is not a good reason for choosing a certain loop control?

Question 17 options:

What the loop does

The minimum number of iterations of the loop

The condition for ending the loop

If the loop is in a function

Save

Question 18 (1 point)

int x;

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

++x;
cout << x;
}

What is the first thing printed by the above code?

Question 18 options:

-1

0

1

2

Nothing is printed

Save

Question 19 (1 point)

Question 19 options:

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 20 (1 point)

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

What is the last thing printed by the above code?

Question 20 options:

0

1

2

8

9

10

11

Nothing is printed

The code never ends

-1

0

1

2

Nothing is printed

Explanation / Answer

Question 1 - Here, the code prints x value after every post-increment. The actual output is like 12345678910. So the first value printed here is 1.


Question 2 - in this code, x value is increased by 1 from 0 to 10 through FOR loop. When x reaches 10,it exit the loop and prints the final value as 10. pre/post increment will not make any difference.


Question 3 - It almost similar to Question 1, but the code prints x value before every post-increment.Hence the actual output is like 0123456789. So the last value printed is 9.


Question 4 - Here, initially x is assigned to 0 and when it enters while loop condition checks where x is greater than 10. since x is 0 , it will not get into the loop and print anything.  

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