What will be the output of the following program? Void main () { int i ; for…

2025

What will be the output of the following program?

Void main ()

{

int i ;

for (i = 0 ; i < 3 ; i ++);

printf ("%d ", i);

}

  1. A.

    3

  2. B.

    0 1 2

  3. C.

    0 1 2 3

  4. D.

    Errors

Attempted by 170 students.

Show answer & explanation

Correct answer: A

The for loop contains a semicolon immediately after the increment statement, creating an empty body. The variable i increments from 0 until it equals 3 before the loop terminates. Consequently, printf outputs the final value of i, which is 3.

Explore the full course: Mppsc Assistant Professor