Hello,
Recently, I came across a C Program. Its confusing to me. Please clarify how this program gives the output.
i/a = 2/4 = 0.5
SO.. I expect the following as output
But, I got
WHY is this???
Please clarify my doubt..
Thanks in advance,
Recently, I came across a C Program. Its confusing to me. Please clarify how this program gives the output.
Code:
#include <stdio.h>
int main()
{
int i = 2;
float a = 4;
printf("%f %d\n",i/a,i/a);
printf("%d %f\n",i/a,i/a);
return 0;
}
i/a = 2/4 = 0.5
SO.. I expect the following as output
Code:
0.5 0
0 0.5
But, I got
Code:
0.5 0
0 0.0000000
WHY is this???
Please clarify my doubt..
Thanks in advance,