Sail E0 Webinar
Question
Comment on the output of this C code?    int main()    {        float f1 = 0.1;        if (f1 == 0.1)            printf("equal\n");        else            printf("not equal\n");    }
Options:
A .  equal
B .  not equal
C .  Output depends on compiler
D .  None of the mentioned
Answer: Option B


0.1 by default is of type double which has different representation than float resulting in inequality even after conversion.
Output:
$ cc pgm4.c
$ a.out
not equal



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

More Questions on This Topic :


Latest Videos

Latest Test Papers