Pre-increment operator:
(1) Increments the value of the variable by 1
(2) Returns the variable itself.
Post-increment operator:
(1) Saves the current value in a temp variable.
(2) Increments the value of the variable by 1
(3) Returns the value saved in the temp variable
printf ("%d %d %d %d",a,a++,a++,++a);
In the above printf() statement, execution happens from right to left.
"++a" is executed first, so value of "a" becomes 7 and returns "a"
"a++" is executed next, so value of "a" becomes 8 and returns "7"
"a++" is executed next, so value of "a" becomes 9 and returns "8"
latest value of "a" is 9
so after the above steps printf becomes printf("%d %d %d %d", a, 8, 7, a);
that's why output becomes 9 8 7 9