'I have been trying to understand operator precedence but got stuck in this question

I have been trying to understand operator precedence but got stuck in this question.Here is the code:

int i=1;
int a= ++i + ++i + ++i * i++ + i++;

When I calculate using pen and paper, I am getting 26 as the value of a (2+3+4*4+5 => 2+3+16+5 = 26).But when I compile it I am getting 31 as the output.

Could somebody please help me with this.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source