a++
is postfix notation, the value is first incremented, but the previous value is returned, which is then passed intoprinf
.++a
is prefix notation, the value is first incremented before it's passed intoprintf
.
Your code is roughly equivalent to this:
int a = 8;
printf("%d\n", a);
a++;
a++;
printf("%d\n", a);
printf("%d\n", a*a);
return 0;
But it's closer to this (note I'm using the ,
operator, which evaluates each sub-expression but only returns the final sub-expression):
int a = 8; int aTemp;
// a++
printf("%d\n", (aTemp = a, a = a + 1, aTemp) );
// ++a
printf("%d\n", (a = a + 1) );