0
what is the different between for () ; and for () {}
https://www.sololearn.com/post/347212/?ref=app The Ans is 4 But my question is what is the different between For ( i=1;i<4;i++); prinf (" %d",i); And For (i=1;i<4,i++) { printf ("%d ",i); }
4 Respostas
+ 2
You can run in playground and see it..
Using semicolon after for statement cause loop terminate there, not let go out for statement.. So next printf not comes under for loop..
It is same as
for(i=1;i<4;i++){} equal to for(i=1;i<4;i++);
After coming out printf("%d", i) ; executed so ones and i=4 then.
but
for(i=1;i<4;i++)
{
printf("%d", i) ; //this prints i 3 times. 1,2,3
}
+ 2
3<4 is true so prints 3.
But next is 4, when 4<4 is false. And Loop terminated, comes out. So now i=4 outside loop..
0
Thanks
I tried and saw the result but i didn't understand how i became equal to 4
in the first example
i =1<4
2<4
3<4
And print i equal to 3
0
Okay, thank you👍