Advertisements
Advertisements
Question
Which of the following for loop will not be an infinite loop?
Options
for(; ;)for (a = 0; a < 1; a--)for (a = 0; ; a++)for (a = −1; a < 1; a++)
MCQ
Advertisements
Solution
for (a = −1; a < 1; a++)
Explanation:
for(a = -1; a < 1; a++) is not an infinite loop because a starts at -1 and increments until a < 1 becomes false.
shaalaa.com
Is there an error in this question or solution?
