MCQ Single Best Answer Moderate

QIn a C++ for loop, what happens if the increment/decrement step is missing?

for (int i = 0; i < 10;) {
    cout << i;
}

ID: #23076 For Loop in Programming Language 74 views
Question Info
#23076Q ID
ModerateDifficulty
For Loop in Programming LanguageTopic

Choose the Best Option

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

  • A The loop will never end
  • B The loop will result in an error
  • C The loop will run indefinitely
  • D The loop will execute only once
Correct Answer: Option C

Explanation

In C++, if the increment or decrement step is missing, the loop will keep running indefinitely because the loop control variable will never change, and the condition will never become false. For example:

Share This Question

Challenge a friend or share with your study group.