Question discussion

Which of the following causes an infinite loop?

359233Medium DSSSB TGT Computer Science 0 replies 0 views
0
Which of the following causes an infinite loop?
  • Afor (int i = 10; i >5; i--) { }
  • Bdo { } while (0);
  • Cwhile (1) { }
  • Dfor (int i = 0; i < 10; i++) { }
Correct answer: C

Explanation

while (1) never has a false condition, so it loops forever.

Discussion 0

Nobody has replied yet. Start the discussion!