0

why we INITIALISE in for loop like int i=1(must with data type) instead we can initialise outside of loop ex- int i=1 C++

28th Jan 2022, 5:30 PM
Vinit Kumar.
Vinit Kumar. - avatar
4 odpowiedzi
+ 2
Yes. You can as you needed. int i; for(I=0;I<5;I++) { .. } for(int I=0;I<5;I++) { .. } int I=0; for( ; I<5;I++) {.. } for(;;) {.. } All valid, but difference is if you declared inside loop then, it will not exist outside of loop..
28th Jan 2022, 5:36 PM
Jayakrishna 🇮🇳
+ 1
You can do as you like
28th Jan 2022, 5:36 PM
Lisa
Lisa - avatar
0
Thnx
28th Jan 2022, 6:41 PM
Vinit Kumar.
Vinit Kumar. - avatar