+ 1

Direct initial value declaration inside for loop

In C language (Not C++, C#, or other C languages)... Can we declare initial value dirrectly in the for loop? rather than typing: int i; for (i=1; i<5; i++) { } can we type these code instead: for (int i = 1; i<5; i++) { } If we can't do that, why?

15th May 2018, 6:56 AM
Ida Bagus Oka Jeve
Ida Bagus Oka Jeve - avatar
3 Antworten
+ 1
hi, you may describe it the two syntax`es are correct and produce no errors. so, point of view is only for the coder how he wants the program to be coded.
15th May 2018, 7:39 AM
Rajeeb
0
Rajeeb Martin Taylor i've just tried it in SoloLearn, both of them worked without error. So are those Pre ANSI C99 and C99 really matters or it was just worked only in SoloLearn's compiler?
15th May 2018, 8:29 AM
Ida Bagus Oka Jeve
Ida Bagus Oka Jeve - avatar