MCQ
Single Best Answer
Moderate
QWhat is the key difference between a while loop and a do-while loop ?
ID: #23092
Do-While Loop in Programming Language
116 views
Question Info
#23092Q ID
ModerateDifficulty
Do-While Loop in Programming LanguageTopic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer: Option B
Explanation
The fundamental difference between a while loop and a do-while loop is the placement of the condition check. In a while loop, the condition is checked before executing the loop body, so the body may not execute if the condition is false initially. In contrast, in a do-while loop, the condition is checked after the loop body, meaning the loop body will execute at least once, even if the condition is false from the start. This is a crucial feature when you want the loop to run at least once regardless of the condition's initial value, like asking for user input or prompting an action that must occur at least once.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic