To determine this the following step is taking.
1). All of ++i
is determined.
2). The value of i is then used to each term that is ++i
and i++
.
3). All of i++
is determined.
First case:
int k=0;
int i=10;
k = (i++)+(++i);
1) There is one of ++i
so at then end of this step i = 11 (once).
2) Now it become k = (11)+(11);
3) There is one of i++
so at then end of this step i = 12 (once).
Second case:
int k=0;
int i=10;
k = (++i)+(++i);
1) There is one of ++i
so at then end of this step i = 12 (twice).
2) Now it become k = (12)+(12);
3) There is one of i++
so at then end of this step i = 12 (zero time).
I create a test code:
#include <stdio.h>
int main(void) {
int K=0;
int I=10;
K = (I++)+(++I);
printf("I: %d; K: %d\n", I, K);
K=0;
I=10;
K = (++I)+(++I);
printf("I: %d; K: %d\n", I, K);
}
When executed, the result is:
I: 12; K: 22
I: 12; K: 24
Hope this helps.