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 is realloc in c?

585


The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.

1082


What are the types of data types and explain?

679


Why n++ execute faster than n+1 ?

1883


What is the difference between array and structure in c?

580






What are the types of unary operators?

674


How do you print only part of a string?

622


FILE PROGRAMMING

1789


What is the behavioral difference when include header file in double quotes (“”) and angular braces (<>)?

826


Can we assign integer value to char in c?

629


Why is a semicolon (;) put at the end of every program statement?

641


Can you write a programmer for FACTORIAL using recursion?

622


What is the difference between near, far and huge pointers?

639


What is array of structure in c programming?

765


Explain the array representation of a binary tree in C.

742