The o/p of the code snippet:
printf("%f", 9/5);
in my linux gcc 4.6.3 (gcc myprog.c followed by ./a.out):
-0.000000
in codepad.org:
2.168831
Why the difference?
I have referred the links: Why cast is needed in printf? and Implicit conversion in C?, but could'nt make use of it.
Info regarding codepad execution: C: gcc 4.1.2 flags: -O -fmessage-length=0 -fno-merge-constants -fstrict-aliasing -fstack-protector-all
EDIT: More: for the execution of following in (in same program) codepad
printf("%f\n", 99/5);
printf("%f\n", 18/5);
printf("%f\n", 2/3);
printf("%f\n%f\n%f", 2, 3, 4);
printf("%f\n", 2);
the o/p is
2.168831
2.168831
2.168831
0.000000
0.000000
-0.001246
-0.0018760.000000
The first three outputs are same garbage values (and not the last one). Wondering why.