I am using Dev C++ with TDM-GCC 4.9.2 32 Bit compiler. I was trying to find the order of evaluation of expressions in printf function for which i made the program:
#include<stdio.h>
int main(){
int x=0;
printf("%d %d",x++,++x);
return 0;
}
If the order of evaluation turns out to be left to right, then the output will be 0 2 and for right to left the output will be 1 1. But the output comes out to be 1 2. How is this possible? If I write:
printf("%d %d",x++,x);
then the output is 0 1 which indicates that order of evaluation is right to left and instead if i write:
printf("%d %d",x,x++);
then the output is 1 0 which indicates that order of evaluation is left to right. Please explain me why I am getting contradictory outputs.