Computer Applications

Which of the following is an empty loop?

  1. for(i = 0; i < 5; i++);
  2. while (i < 5) i++;
  3. do {i++;} while (i < 5);
  4. All of these

Java Iterative Stmts

5 Likes

Answer

for(i = 0; i < 5; i++);

Reason — The statement for(i = 0; i < 5; i++); has a semicolon at its end. Thus, any statement following it will be treated as outside the for loop.

Answered By

1 Like


Related Questions