+ 2

Why does the output print 12? Should it not finish at 11?

https://code.sololearn.com/ch9eyxP60p5K/?ref=app

2nd Jun 2018, 6:22 AM
Chris Sheffield
Chris Sheffield - avatar
5 odpowiedzi
+ 4
https://code.sololearn.com/c7E7dX7fi7U6/?ref=app
2nd Jun 2018, 6:26 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 3
Let me explain,
2nd Jun 2018, 6:26 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 3
No your code prints the number first and checks the condition, that mean it will print 12 first and then check the condition and break the loop. . . . My code checks the condition first and then prints the number. that means, it will check if number is > 11 it will break. untill 9 it is < 11 and as it became 12 it is greater so it will break the loop before printing that number. if you want to that code please copy it and save it to your account because I wanted to delete it. 😊
2nd Jun 2018, 9:55 AM
Raj Chhatrala
Raj Chhatrala - avatar
+ 2
Ok why did yours stop at 9 and mine printed 12? It's the same code is it not?
2nd Jun 2018, 9:42 AM
Chris Sheffield
Chris Sheffield - avatar
+ 1
Ahhh i see now thank you much. You can delete your code now.
2nd Jun 2018, 10:47 AM
Chris Sheffield
Chris Sheffield - avatar