Home / CSE MCQs / C-MCQs :: Discussion

Discussion :: C-MCQs

  1. 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");
        }
  2. A.
    equal
    B.
    not equal
    C.
    Output depends on compiler
    D.
    None of the mentioned

    View Answer

    Workspace

    Answer : Option B

    Explanation :

    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


Be The First To Comment