MCQ Single Best Answer Moderate

QWhat is the main advantage of using a while loop?

ID: #23089 While Loop in Programming Language 87 views
Question Info
#23089Q ID
ModerateDifficulty
While Loop in Programming LanguageTopic

Choose the Best Option

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

  • A It uses less memory than other loops
  • B It is faster than a for loop
  • C It is better suited for loops with unknown iterations
  • D It can be used to iterate through lists
Correct Answer: Option C

Explanation

The main advantage of a while loop is that it is ideal for situations where the number of iterations is unknown, and the loop should continue running as long as a specific condition remains true. This flexibility makes it useful for tasks like reading input from users, monitoring system states, or performing tasks that depend on external conditions. The other options are incorrect because while loops are not necessarily faster or more memory-efficient, and other loop types (like for loops) can also iterate through lists.

Share This Question

Challenge a friend or share with your study group.