I think, it will be evaluated like
x = x + ( x - x--) ; // the post increment here x-- is pushed into stack for evaluation separately.. then x = x + 1 is updated. But previous calculatuon
x+( x- x--) is evaluated and result is stored in x so overrites x++ value with x +(x-x) which is just equalto x = x + ( x - x) ;
So in loop, x value unchages..
Final value : 9
Hope it helps..
Because post increment, the value uses first in expression then increment
So x - x++ is done like x - x, x++
x += x - x++ is done like
x = ( x + ( x - x ) ), x++
x++ update x but it is overritten by value ( x + ( x - x)) which is actually equal to (x - 0) => x
Instead of storing back in x , use any other variable, you can see x++ value .
I thought, your doubt is in
x += x - x-- result.
Where you not understood my reply.. Tell about specific lines..
But hope it clears now..