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
Is fortran faster than c?
Is a pointer a kind of array?
What is the code for 3 questions and answer check in VisualBasic.Net?
Create a registration form application by taking the details like username, address, phone number, email with password and confirm password (should be same as password).Ensure that the password is of 8 characters with only numbers and alphabets. Take such details for 3 users and display the details. While taking input password must appear as “****”.
What are identifiers in c?
How does free() know explain how much memory to release?
What is a scope resolution operator in c?
What is pass by reference in functions?
What is infinite loop?
please can any one suggest me best useful video tutorials on c i am science graduate.please help me.u can email me to sas29@in.com
What is extern storage class in c?
Explain setjmp()?
Write a program on swapping (100, 50)
How can I remove the trailing spaces from a string?
Is there anything like an ifdef for typedefs?