Zach Rode wrote:. . . add my counter to my sum THEN increase my counter by 1.
Well, sort of. Because the
i++ operator has the highest precedence, you have to regard it as being executed first, but it is applied only to
i. This sounds confusing, but there are actually two values: the value of
i and that of the whole expression
i++. But the value of
i++ is the same as the
old value of
i. So the five values are 1 2 3 4 5, as you said, adding up to 15.
Sorry I don't think the forums let me edit
We had trouble with edits in the past; if you really need an edit ask one of us mods.