int x=10;
int total=10;
do {
total += x++;
}while(x<15);
System.out.println(x);
The output of this program will be 15. I don't understand why 15 is the answer.
I'm not understanding the arithmetic here. Doesn't the "+=" mean total = total + x? And doesn't x++ mean that the next value for x will be x+1?
I don't see why this would not output 20 on the first go around. 21 on the second go around, etc.