Can someone please help me and tell me why the output here is 0.000000 when it supposed to be 2.500000? Its only like that when i put it the first line of print commands, if its in the middle of the print group its going well and goes out 2.500000.. So why its 0? for screenshot click here
#include <stdlib.h>
#include <stdio.h>
int main()
{
int a = 65;
char c = (char)a;
int m = 3.0/2;
printf("%f\n", 5 / 2);
printf("%c\n", c); // output: A
printf("%f\n", (float)a); // output: 65.000
printf("%f\n", 5.0 / 2); // output: 2.5000
printf("%f\n", 5 / 2.0); // output: 2.5000
printf("%f\n", (float)5 / 2); // output: 2.5000
printf("%f\n", 5 / (float)2); // output: 2.5000
printf("%f\n", (float)(5 / 2)); // output: 2.0000
printf("%f\n", 5.0 / 2); // output: 2.5000
printf("%d\n", m); // output: 1
system("PAUSE");
return(0);
}
Thanks , Tom.