0

Please anybody explain this loop

Explain inner working of code. I am confused little bit. how it's Will give output 12. https://code.sololearn.com/cc8bOEP7CaZX/?ref=app

17th Apr 2017, 3:16 PM
Rajesh Kumar (Rj)
Rajesh Kumar (Rj) - avatar
3 Antworten
+ 4
yes, we can, since we've declared and defined (assigned zero to) the variable i before
17th Apr 2017, 3:29 PM
Dinmukhamed Mailibay
Dinmukhamed Mailibay - avatar
+ 2
Tracing i=0 i<5? //0<5 True i = i*i //0*0=0 i+=3 //0+3=3 i<5? //3<5 True i=i*i //3*3=9 i+=3//9+3=12 i<5? //12<5 FALSE, so for loop is over go on next cout<<i //prints 12 I can't really see practical point in using this kind of loops apart from using it in challenges
17th Apr 2017, 3:22 PM
Dinmukhamed Mailibay
Dinmukhamed Mailibay - avatar
0
we can use for loop like this for(;I(5;I++). Because i was study right way of for loop is for(I=0;I<5;I++).
17th Apr 2017, 3:28 PM
Rajesh Kumar (Rj)
Rajesh Kumar (Rj) - avatar