Increment operator behaviour

Today i came across a code which i am not able to understand.It would be great if someone could explain the output and behaviour of the code.

  i=1;
ans=i++ + ++i;

Now output of this code is 4.
I understand that increment operators have right to left associativity.

Now consider this code

i=1;
ans=i++ * ++i;

output of this code is 3.
How? Why does it behave differently in these situations.Can someone please elaborate and explain how to both of the expressions evaluate???

Let’s analyse the case 1

first i=1
ans=i++ (after this ans=1,i=2) as i++ first takes the current value of i for the current operation
and then increment it
ans=i++ + ++i(when you do ++i i becomes 3 from 2) as ++i first increment i and then take the incremented value of i for operation so
ans=1+3, this gives ans=4

Now for 2nd case

i=1
ans=i++ (ans=1,i=2) same as before
ans=i++ * ++i (i was 2 now becomes 3) same as before
so ans=1*3, this gives ans=3

Wait, I couln’t identify the problem.

i++ --> 1; i is now 2

++i --> 3; i is now 3

ans = 1 * 3 = 3

okay i understand now, i read in C by dennis Rithcie that associativity of ++ is from right to left so i thought it would increment from right to left, so i was confused