weird output for C code?

  • Thread starter Thread starter Swakit
  • Start date Start date
S

Swakit

Guest
void main()
{
float j;
j= 1000*1000;
printf("%f",j);
}
this code prints 16960.0000
why?
i did not get reason for this
please explain
thnx
Right i am getting output as 16960.000 for j = 1000*1000
and 1000000.0000 for j = 1000.0*1000.0
but what is the reason behind this i am using turbo c borland 4.0 compiler
 
mite be your compiler... for this code, i get output:
1000000.000000

Without a long explanaition, here is a possible remedy u mite try:

void main()
{
float j;
j= 1000.0 * 1000.0 ; // <<<---------- diff
printf("%f",j);
}
 
Back
Top