main(){
int a = 5;
int b = 6;
printf("%d %d %d",a==b,a=b,a<b);
}
Output in my testing
1 6 1
In above program I am expecting output as 0 6 0 . In some compilers it is giving this output (e.g. Xcode) but where as in some other compilers it is giving output as 1 6 1 . I couldn't find the explanation . It is also the case of Sequence point.
Consider this below program
main(){
int a = 5;
int b = 6;
printf("%d %d %d",a<b,a>b,a=b);
printf("%d %d",a<=b,a!=b);
}
Output in my testing
0 0 6 1 0
this below program is giving the correct output which i am expecting which is 0 0 6 1 0 but why the above program is not giving the output as 060 in most of the compilers
C standard says:
C11: 6.5 (p2):
This means your program invokes undefined behavior. In the statements
and
the side effect to
a
is unsequenced because standard says: