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

It will print "not equal". Reason is the difference in
precision of the numbers. ie numbers like 8.8 or 8.1 can't
be stored with complete precision in binary sysetm since
it's mantissa part will not end but continues with a
series. So value calculated for single precision(float)
number will be slightly different from the value calculated
for double precision (double) number. To verify this use
gcc and gdb in linux.

If you try with numbers 8.25, 8.5 or 8.75 the program will
print "equal" since the mantissa part ends with in the
precision.

I think this has nothing to do with compiler version or
inabilty of comparision.

Is This Answer Correct ?    10 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is array in C

1108


Write a program to print numbers from 1 to 100 without using loop in c?

1039


What is "Duff's Device"?

1128


What are the types of pointers?

1048


Explain what is the benefit of using const for declaring constants?

980


What is the time and space complexities of merge sort and when is it preferred over quick sort?

1023


Explain zero based addressing.

975


write a c program in such a way that if we enter the today date the output should be next day's date.

2153


What is an endless loop?

1240


Can a void pointer point to a function?

978


Is boolean a datatype in c?

1021


What is the significance of an algorithm to C programming?

1012


What does struct node * mean?

982


Why is c known as a mother language?

1196


Write a program to find the biggest number of three numbers in c?

1018