why the answer is 0 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

why the answer is 0

int m=100 while(true){if (m<10){break;} m - =10 System.out.print("m=" + m) }

26th Dec 2018, 1:55 PM
Ahmad Ali
Ahmad Ali - avatar
2 Answers
+ 4
while loop will stop when m <10 (if (m <10) {break;}), the number m decreases by 10 with each iteration (i.e. 100, 90, 80 ... ... 10, 0), therefore the loop stops when m is 0
26th Dec 2018, 2:21 PM
Игорь Яковенко
Игорь Яковенко - avatar
+ 2
thank you very much
26th Dec 2018, 4:22 PM
Ahmad Ali
Ahmad Ali - avatar