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);

  1. A.

    1245

  2. B.

    0000

  3. C.

    Error

  4. 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.

Explore the full course: Up Lt Grade Assistant Teacher 2025