+ 1
Why output is 17?
int result = 0; for (int i = 0; i < 5; i++) { if (i == 3) { result += 10; } else { result += i; } } System.out.println(result);
4 Respostas
+ 6
If you hand trace the execution of the code, you will get a sum of
0, 1, 2, 10, 4
to result. The result is then printed, which is the value 17.
Btw, you can actually use the search bar. I remember answering to this since an eternity ago.
https://www.sololearn.com/Discuss/497243/?ref=app
+ 1
Hatsy Rei thank you
0
Supriya Gangapatnam thank you 👍🏻