+ 1

Why is this 11

Var x = 1 For(;x<6;x+=2){ X=x*x } Can somebody please explain why the output is 11? I understand that without the x=x*x part the code output would be 1 3 5 So how does this become 11? Thanks

14th Feb 2019, 8:44 PM
Luke Sandford
2 Réponses
+ 3
step 1: x=1, so x*x=1 For the next round add 2, then x=3 step 2: 3*3=9 For the next round add 2, then x=11 step 3: there is no step left, because the if clause ends when x is becomes larger than 6. The final output will thus be: x=11 😁
14th Feb 2019, 10:48 PM
marjel101
marjel101 - avatar
+ 1
Could you fix the syntax and also there should be no output
14th Feb 2019, 9:01 PM
Juho Pesonen
Juho Pesonen - avatar