main()
{
float a=8.8;
double b=8.8;
if(a==b)
printf("Equal");
else
printf("not equal");
getch();
}
what is the output?
with reason
Answer Posted / rakesh
It will print "not equal". Reason is the difference in
precision of the numbers. ie numbers like 8.8 or 8.1 can't
be stored with complete precision in binary sysetm since
it's mantissa part will not end but continues with a
series. So value calculated for single precision(float)
number will be slightly different from the value calculated
for double precision (double) number. To verify this use
gcc and gdb in linux.
If you try with numbers 8.25, 8.5 or 8.75 the program will
print "equal" since the mantissa part ends with in the
precision.
I think this has nothing to do with compiler version or
inabilty of comparision.
Is This Answer Correct ? | 10 Yes | 0 No |
Post New Answer View All Answers
Not all reserved words are written in lowercase. TRUE or FALSE?
What is hungarian notation? Is it worthwhile?
List some of the static data structures in C?
What type of function is main ()?
What functions are in conio h?
What is the right type to use for boolean values in c?
Write a c program to demonstrate character and string constants?
When should the volatile modifier be used?
What is context in c?
Is that possible to store 32768 in an int data type variable?
What kind of structure is a house?
Explain how can you avoid including a header more than once?
What is structure in c definition?
How can I handle floating-point exceptions gracefully?
What are the two types of structure?