MCQ
Single Best Answer
Moderate
QWhat will happen if the loop control variable in a for loop is modified inside the loop?
ID: #23079
For Loop in Programming Language
86 views
Question Info
#23079Q ID
ModerateDifficulty
For 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
Modifying the loop control variable inside the loop can lead to unexpected behavior. For instance, if the variable controlling the number of iterations is altered in the body of the loop, it could cause the loop to terminate prematurely, skip iterations, or even result in an infinite loop. It is generally not recommended to modify the control variable inside a loop, as it can lead to logic errors and unpredictable outcomes.
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic