+ 1
Would you tell me why this output is 2?
int x = 0; for (int i=10; i>0;i=i-x){ x++; if(i%2==1){ break; } } System.out.print(x);
2 Answers
+ 7
i starts as 10. x becomes 1. Next loop, i is 9 and x becomes 2. 9%2 is 9-8=1 so we break out of the loop. We print x of 2.
+ 1
oo, I got it, thank you John Wells