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 / vignesh1988i

here it will print : either NOT EQUAL or EQUAL
according to me and my compailer it's NOT EQUAL only.......
depends upon the compailer actually......

here variable 'a' is assigned wit float and 'b' is assigned
with double....
here comes the problem ie. of allocation of no. of bytes

according to my compailer float allocates 4 bytes and double
allocates 8 bytes.... so when it compares each location bit
by bit the float will lag by two bytes of space than double
has .. so since the comparsion takes a decision tat it's not
equal since it dosent check the other two locations of
double wit float which is lagging wit that two bytes of
memory space....... so it prints NOT EQUAL


thank you

Is This Answer Correct ?    19 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the code for 3 questions and answer check in VisualBasic.Net?

1697


What is a const pointer?

642


What is a scope resolution operator in c?

757


I completed my B.tech (IT). Actually I want to develop virtual object that which will change software technology in the future. To develop virtual object what course I have to take. can I any professor to help me.

1747


Explain how can I convert a number to a string?

652






What is #define?

581


Array is an lvalue or not?

645


What is define directive?

648


Does sprintf put null character?

610


What do header files do?

611


What is the best style for code layout in c?

637


What is pragma c?

625


What does %c do in c?

595


Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.

728


Why doesnt the call scanf work?

680