Why is this C program giving a wrong output?

Posted by JMSA on Stack Overflow See other posts from Stack Overflow or by JMSA
Published on 2010-05-11T06:26:39Z Indexed on 2010/05/11 6:34 UTC
Read the original article Hit count: 102

Filed under:

Why is this C program giving a wrong output?

#include<stdio.h>

void main()
{
    float f = 12345.054321;

    printf("%f", f);

    getch();
}

Output:

12345.054688

But the output should be, 12345.054321.

I am using VC++ in VS2008.

© Stack Overflow or respective owner

Related posts about c