Home » C Programming » Data Types » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    int main()
    {
    float num1 = 0.2;
    if (num1 == 0.2)
    {
    printf("Equal\n");
    }
    else
    {
    printf("Not Equal\n");
    }
    }
    1. Compilation Error
    2. 0.2
    3. Equal
    4. Not Equal
    5. None of these
Correct Option: D

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



Your comments will be displayed only after manual approval.