Recently I've come across this code, Which I assumed to understand and didn't bother to run, My answer (that i assumed in my head) was confirmed by the book Let Us C. Later when I try to give it a run in C, to my surprise the output was completely contrasting. C++ is giving the output which I expected.
C++ :
int a=1;
cout<<a<<a++<<++a;
Output :
113
C :
int a=1;
printf("\n%d %d %d",a,a++,++a);
Output:
3 2 3
I expected this to be the same as the output produced by C++.
I don't have a very clear understanding of Precedence and Associativity of Operator. But this output seems to be out of blue.
I'm using Atom as an editor and C / C++ compiler GCC.