Data Type MCQ 1 : Comparing Floating Point Value with Double in C



In C Programming (Multiple Choice Question 1 ) Comparing Floating Point Value with Double


#include<stdio.h>
void main()
{
float num1 = 1.1;
double num2 = 1.1;
if(num1==num2)
    printf("Stanford");
else
    printf("New Delhi");
}

Options : 

  1. Stanford
  2. New Delhi
  3. Compile Error
  4. Run Time Error


Why & How ?

  • Float store floating point numbers with 8 place accuracy
    and requires 4 bytes of Memory.
  • Double has 16 place accuracy having size of 8 bytes
  • For floating point numbers (float, double, long double) the values cannot be predicted exactly.