Originally posted by Shimi Avizmil:
doesn't matter what the values are, sun's explanationwas that the above equation is the same as :
result = result + (i * (j-1) ) + 1.
Actually, the original values DO matter. The original values were:
i = 3;
j = 0;
result = 1; <-- this is where the "+1" is from!!
And Sun's response was NOT:
result = result + (i * (j-1) ) + 1
It was:
Resolves to (i * (j-1) ) + 1
It wasn't supposed to be interpreted as a "general formula" but rather as the result of this *particular* expression, which in this case involves an original value of "1".
So the "+1" is not reflecting the post-increment operation, but rather the "1" that was the original value of result.
So the question and answer are correct, but I think the answer is really confusing, and I can see how it could easily be misinterpreted.
I'll see if we can add a better, more detailed explanation up there.
Thanks!!