(float)9/5 is casting only 9 not the result of 9/5. So the / operation isn't an integer operation at this point. (float)(9/5) will give the result 1.00000.
Try compiling with all warnings, and it will probably tell you a lot of what is wrong.
For example on a 64-bit linux system, compiling with gcc -Wall I get:
pf.c: In function ‘main’:
pf.c:6:2: warning: format ‘%f’ expects argument of type ‘double’, but argument 3 has type ‘int’ [-Wformat]
pf.c:6:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat]
pf.c:6:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 5 has type ‘long unsigned int’ [-Wformat]
As mentioned above you need the correct format specifiers. Using the right format specifiers and casting gives:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
printf("%f %f %lu %lu\n",(float)(9/5),(float)4,sizeof(float),sizeof(int));
return 0;
}
gives:
snits@perelman:~/proj/c=>./pf
1.000000 4.000000 4 4