0

Can anyone explain this to me?

What is the output of this loop and if it gives nothing why ?! If i is an integer and initialize to 1. for(i<5;i=0;i++) { printf("%d",i); }

9th Nov 2018, 4:28 PM
Mohammed Alnaggar
Mohammed Alnaggar - avatar
3 Respuestas
+ 7
Variable "i" needs to be declared as type int. You need somthing like.. for(int i = 0; i<5;i++){ printf("%d",i); }
9th Nov 2018, 5:07 PM
D_Stark
D_Stark - avatar
9th Nov 2018, 5:20 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 6
Assuming you had a main function and declared i around your loop. Your loop doesn't enter as i=0 is false so the exit condition was met. D_Stark fixed your loop to output 0 to 4.
9th Nov 2018, 5:14 PM
John Wells
John Wells - avatar