+ 10
Mofey at the end of the second iteration x has a value of 3*3==9 and just before the third iteration x becomes 9+2==11, so the third iteration never happens because 11<6 is false.
25th Jun 2019, 6:14 AM
Sonic
Sonic - avatar
+ 7
Do you get 11? You are writing x outside and after executing the loop using the final value of x.
25th Jun 2019, 5:56 AM
Sonic
Sonic - avatar
+ 3
Let's run through it. x starts off as 1, then gets squared (still 1), then incremented (3), then squared (9), then incremented again (11) The reason you are confused, that at the end of each iteration, it runs the last part of the for loop even if the condition is false
25th Jun 2019, 5:55 AM
Airree
Airree - avatar