One doubt
Remember Postincrement operator increments the value only after the execution of the current statement (in this case - y = x++ + ++x; )
Before the statement, x is -1 and y is 0.
So as per the explanation above the code must translate to:
y should not get the value from x++ (thats what I thought) but it does.
In fact it behaves as if the code was
That is the only way y can end up with 1 else it should be -1.
May be I am missing some concept here/I might be confused but that is how it works.
I am guessing this has something to do with priority while evaluating an expression. I think ++ has higher priority than +.
Any references will be helpful.
Thanks in advance for any help.