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);
}
- A.
3
- B.
0 1 2
- C.
0 1 2 3
- 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.