What will be the output of the following ‘C’ code? for (i = 1; i < 5; i++) if…
2026
What will be the output of the following ‘C’ code?
for (i = 1; i < 5; i++)
if (i != 3)
printf ("%d", i);
- A.
1245
- B.
0000
- C.
Error
- D.
12345
Attempted by 228 students.
Show answer & explanation
Correct answer: C
In C, variables must be declared before use. The code uses the variable 'i' in the for loop without declaring its type (e.g., int i;). This results in a compilation error, so the program will not produce any output.