In your second code snippet you have a semicolon ; after the for loop for (i = 0; i < 5; i++);.
;
for (i = 0; i < 5; i++);
i++
i
5