Explain the output . Program has been compiled on gnu (gcc 4.9.2 compiler)
#include <stdio.h>
main()
{
int i=1;
int arr[]={2,3,4,5};
int x=(i++<3);
printf("%d %d %d %d %d",i,x,++i[arr],i++[arr],i);
}
output :3 1 6 4 3
Explain the output . Program has been compiled on gnu (gcc 4.9.2 compiler)
#include <stdio.h>
main()
{
int i=1;
int arr[]={2,3,4,5};
int x=(i++<3);
printf("%d %d %d %d %d",i,x,++i[arr],i++[arr],i);
}
output :3 1 6 4 3
What you have here is a "side effect". Depending on the underlying architecture, the parameters to printf() are evaluated from left-to-right or from right-to-left (f.e. HPUX).
So you cannot say, what is "THE" result. You can only specify the result on your operating system with your compiling chain.
This behaviour is called Undefined behavior and sequence points