There two points need to notice here before answer the question.
Point 1. End of the FOR loop
look at carefully for loop in above program
for(;i++;printf("%d",i));
semicolon at end of the loop, it same as (nothing inside the for loop code block)
for(;i++;printf("%d",i)
{
//nothing
}
it's clear that
print("%d",i) at 6th line is not part of the FOR loop code.
-------------------------------------------------------------------------------------------------------------------
Point 2 : FOR loop syntax
for (initialization statement; test expression; update statement) {
// statements
}
in above code for ( ; i++ ; prinft("%d",i))
initialization statement =
test expression= i++
update statement= printf("%d",i)
How FOR loop execute the flow ?
Now let's crack the above program.
Init : before FOR loop , i value is already assigned to 0 (i=0)
Next , Condition check : Test Expression is i++
i++ is postfix increment , so value is of i is zero (i=0 while evaluating the expression) but increment will happen after condition check.
Expression check in for loop is simple as if(Expression)
if(0) -> return false ,thus control doesn't go into for loop.
Now program control out of for loop and value of i will be 1 (i=1, because of postfix increment).
Next statement is line 6, Prinft("%d",i);
So, output is 1