What is the output of the following C code? #include int main() { int index;…
2011
What is the output of the following C code?
#include
int main()
{
int index;
for(index=1; index<=5; index++)
{
printf("%d", index);
if (index==3)
continue;
}
}
- A.
1245
- B.
12345
- C.
12245
- D.
12354
Attempted by 752 students.
Show answer & explanation
Correct answer: B
The loop iterates from index 1 to 5. Inside the loop, printf executes before the continue statement. Therefore, even when index is 3, it prints '3' before continuing to the next iteration. All numbers from 1 through 5 are printed sequentially without spaces, resulting in the output '12345'.