What is the output of this C Program? <pre class="prettyprint"> #include <stdio.h> int main() { float f1 = 0.1; if (f1 == 0.1) printf("equal\n"); else printf("not equal\n"); } </pre>

Data Types in C Language - General Knowledge Question and Answer

What is the output of this C Program?
#include <stdio.h>
int main()
 {
  float f1 = 0.1;
  if (f1 == 0.1)
    printf("equal\n");
  else
    printf("not equal\n");
 }
 


not equal
equal
Output depends on compiler
None of the mentioned

Answer:

Output

not equal

0.1 by default is of type double which has different representation than float resulting in inequality even after conversion.


Share Me: