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

What are the 4 types of functions?

581


program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

1634


What does the && operator do in a program code?

707


What are the different data types in C?

736


What is f'n in math?

628






What is the deal on sprintf_s return value?

649


What is the purpose of sprintf?

629


Explain what header files do I need in order to define the standard library functions I use?

655


Give me the code of in-order recursive and non-recursive.

895


What is a program flowchart and how does it help in writing a program?

674


c program to compute AREA under integral

1821


How are variables declared in c?

607


Is it better to use malloc() or calloc()?

658


What are file streams?

574


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

620