+ 1

Can someone explain this

#include <iostream> using namespace std; int main (){ int x=1; for(;x<6;x+=2){ x=x*x; } cout<<x; }

13th Jan 2017, 12:26 PM
Emanuel Dajti
Emanuel Dajti - avatar
3 Respuestas
+ 22
1*1=1 //First run 1+2=3 //Increment after run // check whether 3<6? 3*3=9 //Second run 9+2=11 //Increment after run // check whether 11<6? out of loop.. print
13th Jan 2017, 12:48 PM
Frost
Frost - avatar
+ 18
11
13th Jan 2017, 12:46 PM
Frost
Frost - avatar
+ 1
That is the logic in S!d answer! What more do you want?
13th Jan 2017, 2:58 PM
Mitran Constantin Bogdan
Mitran Constantin Bogdan - avatar