0

[solved] Why I'm confused?!?!!!

Why this code print hello once yet 1 isn't greater 0 https://code.sololearn.com/wfh1wi0X59z4/?ref=app

26th Feb 2020, 12:18 PM
Mohammad
Mohammad - avatar
3 Respuestas
+ 3
x = 0; y = 5; do { print "x =" x //This code will run BEFORE checking condition } while ( x > y) Output: x = 0 Condition is false ( 0 is not bigger than 5) so loop is over.
26th Feb 2020, 12:34 PM
HNNX 🐿
HNNX 🐿 - avatar
+ 3
It's still printing hello because with a do while loop, the block of code in the do part of the loop with run once, then check the conditions for the first time.
26th Feb 2020, 12:36 PM
Aiki
Aiki - avatar
+ 1
Thanks
26th Feb 2020, 12:37 PM
Mohammad
Mohammad - avatar