Multiple choice

What would be the output of the following?

main() { int i,j; for(i=0;;i++) for(j=0;;j++) if(j>100) break; printf("%d%d",i,j); }

  1. System Hangs

  2. 100 100

  3. 0 100

  4. 1 100

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The outer for loop has no condition (empty middle clause), so it's infinite: for(i=0;;i++). The inner loop is also infinite: for(j=0;;j++). The break only exits the inner loop when j>100, but then the inner loop restarts with j=0. This continues forever, causing the system to hang.