English

Which of the following for loop will not be an infinite loop? - Computer Applications

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

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?
Chapter 1.09: Iterative Constructs in Java - EXERCISES [Page 122]

APPEARS IN

Avichal Computer Applications [English] Class 10 ICSE
Chapter 1.09 Iterative Constructs in Java
EXERCISES | Q I. 2. | Page 122
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×