C++ Loops

Last Updated :
Discuss
Comments

Question 1

Which of the following is not a loop in C++?

  • for

  • repeat

  • while

  • do-while

Question 2

Which loop checks the condition at the end?

  • for

  • while

  • do-while

  • if-else

Question 3

How many times will a while loop execute if the condition is initially false?

  • 0

  • 1

  • 2

  • Infinite

Question 4

Which keyword is used to exit from a loop early?

  • skip

  • end

  • break

  • Exit

Question 5

Which loop is preferred when the number of iterations is known?

  • while

  • do-while

  • for

  • switch

Question 6

Which of the following affects the control flow inside a loop?

  • continue

  • goto

  • break

  • All of the Above.

Question 7

What happens if a semicolon is placed immediately after the for loop declaration?

C++
for( int i=0; i<5; i++);


  • Compilation error

  • Infinite loop

  • Only loop control executes, body skipped

  • Body executes normally

Question 8

What is the output of this code snippet?

C++
int i = 0;
while (i < 3)
    ++i;
cout << i;


  • 2

  • 3

  • 4

  • Error

Question 9

Which loop is guaranteed to execute at least once regardless of the condition?

  • for

  • while

  • do-while

  • All of the Above

Question 10

What happens if the loop control variable is not updated in a while loop?
Note: Assume that the condition is initially true.

  • Error

  • Infinite loop

  • Executes once

  • None

Tags:

There are 19 questions to complete.

Take a part in the ongoing discussion