Multiple choice

What is the output of the following code? #include<stdio.h> void main ( ) { int s=0; while (s++<10) { if(s<4&&s<9) continue; printf(“ %d/t”,s); } }

  1. 1 2 3 4 5 6 7 8 9

  2. 1 2 3 10

  3. 4 5 6 7 8 9 10

  4. 4 5 6 7 8 9

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

The while loop increments s using post-increment (s++). Initially s=0, after check s becomes 1. The condition (s<4 && s<9) is true for s=1,2,3, so continue skips printf. When s=4, the condition fails and printing starts. Output continues through s=10 when the loop condition (10<10) becomes false. Output: 4 5 6 7 8 9 10