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 / pushkar pahare

This problem has different answers on different compilers.
I had used turboc3, where is always printf "not equal".
Because the size of float is 2 bytes and size of double is
4 bytes, So, when compiler checks this, it can only compare
two bytes rest are left un checked and thus it concludes
false condition. It is same on RHEL5 environment.

Where as on Visual Studio 6.0, It will yield "Equal",
because here both the float and double variable acquires
the same space in memory. Thus the compiler can compare all
four bytes of memory which in fact contains the same values
because the representation of value is same in float and in
double.

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to reverse a linked list in c.

843


Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

858


Are the variables argc and argv are local to main?

969


What is a list in c?

779


WRITE A PROGRAM TO MERGE TWO SORTED ARRAY USING MERGE SORT TECHNIQUE..

1779


Is file a keyword in c?

674


What is the difference between fread buffer() and fwrite buffer()?

884


the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

836


What is anagram in c?

686


to find the closest pair

2040


What is structure data type in c?

734


Does free set pointer to null?

733


What are control structures? What are the different types?

815


When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

808


Differentiate between a structure and a union.

993