I wish to know that why this code shows different Output on different compilers. Here's the Code:-
int a = 5;
printf("%d %d",a++,++a);
Output:- 6 7 (Visual Studio)
Output:- 6 6 (CodeBlocks)
I wish to know that why this code shows different Output on different compilers. Here's the Code:-
int a = 5;
printf("%d %d",a++,++a);
Output:- 6 7 (Visual Studio)
Output:- 6 6 (CodeBlocks)
This is undefined behavior and it depends on the compiler which you are using. And to add it has nothing to do with the order of precedence.
You may check Precedence and Order of Evaluation
Also from C99 standard:
The order of evaluation of the operands is unspecified. If an attempt is made to modify the result of an assignment operator or to access it after the next sequence point, the behavior is undefined.