Single Choice Not Set

QWhat 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");
 }

ID: #891 Data Types in C Language 2,263 views
Question Info
#891Q ID
Not SetDifficulty
Data Types in C LanguageTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A not equal
  • B equal
  • C Output depends on compiler
  • D None of the mentioned
Correct Answer

Explanation

Output

not equal

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

Share This Question

Challenge a friend or share with your study group.