Computer Applications
Which of the following for loop will not be an infinite loop?
- for(; ;)
- for(a = 0; a < 1; a--)
- for(a = 0; ; a++)
- for(a = -1; a < 1; a++)
Java Iterative Stmts
12 Likes
Answer
for(a = -1; a < 1; a++)
Reason — In the selected for loop, the initial value of a (-1) will be incremented by 1 every time and eventually the condition (a < 1) will become false and the loop will terminate.
Answered By
5 Likes
Related Questions
Which of the following statements will terminate the premature execution of a program?
- System.exit(0)
- break
- stop
- end
Choose the odd one out from the following:
- return
- break
- continue
- if-else
The while statement repeats the execution of a block only when the given condition is:
- False
- True
- 1
- 0
Which of the following is not a part of the looping construct?
- close
- for
- break
- continue