- 1

What are the values of the variables s and x after running this piece of code?

int s = 12; int x = 87; do { s = x; x -= 40; }while (x < 20);

18th Mar 2021, 5:56 PM
Charityn
2 Antworten
+ 4
first loop: s = 87, x = 47. Second loop cannot be executed because x is greather than 20. do-while loop executes at least one loop, what cannot be done with while loop.
18th Mar 2021, 6:16 PM
JaScript
JaScript - avatar
0
try it by yourself, by running it in a code playground ;P
18th Mar 2021, 5:58 PM
visph
visph - avatar