C Programming :: Variables & Data Types - Discussion
Home > C Programming > Variables & Data Types > MCQs Questions Discussion
41 / 51
What will be output of the following "c" code?
#include
void main ( )
{
float x=0.7;
if( x== 0.7)
printf("equal");
else
printf ("not equal");
}
void main ( )
{
float x=0.7;
if( x== 0.7)
printf("equal");
else
printf ("not equal");
}
Aequal
Bnot equal
CCompilation Error
DNone of these
Answer: Option (Login/Signup)
Show Explanation
Asked In ::
STEP-BY-STEP
This is because of rounding the value of variable a.
i.e.
a=0.7 is rounded to
=0.699999988
And, the constant 0.7 is as
=0.69999999999
so a<0.7 is true so it prints not equal.
Read Full Answer
Report Error
Please Login First Click Here