MCQ Single Best Answer Easy

QHow can you exit a do-while loop prematurely in C++?

ID: #23098 Do-While Loop in Programming Language 88 views
Question Info
#23098Q ID
EasyDifficulty
Do-While Loop in Programming LanguageTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A break
  • B continue
  • C exit()
  • D return
Correct Answer: Option A

Explanation

In C++, you can exit a do-while loop prematurely using the break statement. When the break statement is encountered inside the loop body, the loop is immediately terminated, and control moves to the statement following the loop. The continue statement, on the other hand, only skips the current iteration and proceeds with the next one. The exit() function terminates the entire program, and return exits the current function, not just the loop.

Share This Question

Challenge a friend or share with your study group.