Consider these two programs:
#include <stdio.h>
int main()
{
int z = 6.4;
printf("%d %d", z, 6.4);
return 0;
}
Output is 6 -1717986918
.
#include <stdio.h>
int main()
{
int z = 6.4;
printf("%d %d", 6.4, z);
return 0;
}
Output is -1717986918 1075419545
.
Why does the output vary like that? When z
was first then the output printed correct z
value which was 6
as z
is an integer, but when I reversed the arguments, the output is a different value. Why does it behave like that?