#include <stdio.h>
main()
{
int a=1;
printf("%d %d %d %d %d\n",++a,a++,++a,++a,a++);
a=1;
printf("%d %d %d %d %d",a,a++,a,++a,a);
}
When I run it , it gives following output.
6 4 6 6 1
3 2 3 3 3
Please explain the code.
The order of evaluation of function arguments is not defined, so the ++
operators could be applied in any order. You're looking at the results of undefined behaviour.