In the following program
#include<stdio.h>
int main()
{
int a;
a=5; printf("%d %d %d\n", a, a++ , a++); //statement 1
a=5; printf("%d %d %d\n", a, ++a , ++a); //statement 2
return 0;
}
Output
7 6 5
7 7 7
My question why there is different behavior with a++ and ++a. I know in variable length argument it is executed from left to right and statement 1 make sense but I am wondering the result for statement2 and I was expecting results like 7 7 6..Am I missing something here ?