do-while vs do loop Quiz

do-while vs do loop Quiz

9th - 12th Grade

5 Qs

quiz-placeholder

Similar activities

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

Basics of Coding and AI Applications

Basics of Coding and AI Applications

11th Grade

10 Qs

do-while vs do loop Quiz

do-while vs do loop Quiz

Assessment

Quiz

others

9th - 12th Grade

Practice Problem

Medium

Created by

Anna Niewodniczanska

Used 4+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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?