This becomes (remember that k = 1 at this point): k = 1 + 3 + (++k) i.e. k = 1 + 3 + 2; (at this point value of k is 2 because of ++k). But the value of Right Hand Side has not yet been assigned to k. k = 6; 6 is assigned to k thereby overwriting the value of 2.
Why doesn't it equate to k = 2 + 3 + 2 if k is incremented?
but isn't it pre-increment's associativity is Right to Left?
I was expecting ++k will be evaluated first since it is of higher precedence compared to arithmentic ( addition ) and assignment (+=):
1. ++k is evaluated first since it has the highest precedence of them all and its associativity is R-L. Thus k = 2.
2. K+3 becomes 2 + 3 = 5 (>>>k is still 2)
3. 5 + 2 = 7.