Which of the following for loops will be an infinite loop? for(; ;)for(i=0 ; i<1; i--) for(i=0; ; i++) All of the above
Question
Solution 1
All of the above will result in an infinite loop.
for(; ;)
: This loop will run indefinitely because there is no condition specified to terminate the loop.for(i=0 ; i<1; i--)
: This loop will also run indefinitely. The initial condition isi=0
, and the loop will decrementi
by 1 in ea Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study prob
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solve study problem.
Knowee AI StudyGPT is a powerful AI-powered study tool designed to help you to solv
Similar Questions
Which of the following for loops will be an infinite loop? for(; ;)for(i=0 ; i<1; i--) for(i=0; ; i++) All of the above
Convert the following while loop to a for loop such that the output remains same.int i = 20;while (i > 0){cout << i << “\t”;i = i - 2;}
The output of the code is ___. int fact=1; for (i=1; 4; i++) { fact=fact*i; printf(“%d”, fact); } 120 Infinite loop 24 6
What will be the value of "i" in the following "for loop" statement?for i in range(1, 6): print(i)
How many times will the following "for loop" iterate?for i in range(5): print(i)