Search Header Logo

do-while vs do loop Quiz

Authored by Anna Niewodniczanska

others

9th - 12th Grade

Used 4+ times

do-while vs do loop Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

5 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

10 mins • 3 pts

What is the main difference between a while loop and a do-while loop?

A: A while loop checks the condition before executing the loop body, while a do-while loop checks the condition after executing the loop body.
B: A while loop can iterate an infinite number of times, while a do-while loop cannot.
C: A while loop is used for definite iteration, while a do-while loop is used for indefinite iteration.
D: There is no difference between them.

2.

MULTIPLE CHOICE QUESTION

10 mins • 3 pts

How many times will the following loop execute? int x = 5; do { cout << x << endl; x--; } while (x > 0);

A: 0 times
B: 4 times
C: 5 times
D: Infinitely

3.

MULTIPLE CHOICE QUESTION

10 mins • 3 pts

What is the output of the following code? int num = 0; do { cout << num << " "; num += 2; } while (num < 5);

A: 0 2 4
B: 0 2 4 6
C: 2 4
D: 2 4 6

4.

MULTIPLE CHOICE QUESTION

10 mins • 3 pts

What is the output of the following code? int i = 0; while (i < 5) { cout << i << " "; i--; }

A: 0 1 2 3 4
B: 0 -1 -2 -3 -4 .......................never ends
C: no output
D: 4 3 2 1 0

5.

MULTIPLE CHOICE QUESTION

10 mins • 3 pts

Which of the following is a valid syntax for a do-while loop in C++?

A: do { // code } while (condition);
B: do while (condition) { // code }
C: do { // code } while condition;
D: do while (condition); { // code }

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Similar Resources on Wayground