do-while vs do loop Quiz

do-while vs do loop Quiz

9th - 12th Grade

5 Qs

quiz-placeholder

Similar activities

6.1 -6.5

6.1 -6.5

9th Grade

5 Qs

Practice Quiz for M22 L4: The Allied Victory 24-25

Practice Quiz for M22 L4: The Allied Victory 24-25

9th - 12th Grade

10 Qs

Tkinter-Entry

Tkinter-Entry

9th Grade

10 Qs

letter

letter

11th Grade

10 Qs

do-while vs do loop Quiz

do-while vs do loop Quiz

Assessment

Quiz

others

9th - 12th Grade

Medium

Created by

Anna Niewodniczanska

Used 3+ times

FREE Resource

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 }