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
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.
+ 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.
+ 1
Thanks