pagano monello wrote:the result surprises me. In fact I expected 21, it seems to me that the postfix hasn't been valued. Any suggestion about it?
Because it's postfix, the value of a (10) is used first and then it's incremented with 1 (a=11) and then the result of the sum (20) is assigned to a. It's much more clear if you use another variable to store the sum like in this example
And this topic has a very informative discussion about post-increment (or post-decrement) operators. So if you have some doubts, it's definitely worth reading. And if you still have some doubts after reading that topic, just let us know by hitting the reply button
Hope it helps!
PS. You are using the postfix increment operator in your example, but the title suggests the decrement operator. I updated the title accordingly, hope that's ok for you.