Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 two forms of #include directive?

1108


Why flag is used in c?

1078


How main function is called in c?

1080


How do you override a defined macro?

1215


What is scope and lifetime of a variable in c?

998


Tell me the use of bit field in c language?

1023


Explain how can a program be made to print the name of a source file where an error occurs?

1148


What is modeling?

1006


Write a code to generate divisors of an integer?

1013


How can I split up a string into whitespace-separated fields?

1015


can any one please explain, how can i access hard disk(physical address)? it is possible by the use of far,near or huge pointer? if yes then please explain......

1814


How do we print only part of a string in c?

982


How old is c programming language?

973


What are the uses of null pointers?

1046


Tell us the use of fflush() function in c language?

1097