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
What is the difference between array and pointer?
What is dynamic dispatch in c++?
Write a function stroverlap that takes (at least) two strings, and concatenates them, but does not duplicate any overlap. You only need to worry about overlaps between the end of the first string and the beginning of the second string. Examples: batman, manonthemoon = batmanonthemoon batmmamaman, mamamanonthemoon = batmmamamanonthemoon bat, man = batman batman, batman = batman batman, menonthemoon = batmanmenonthemoon
How was c created?
how much salary u want ? why u join in our company? your domain is core sector why u prefer software ?
Is c still used?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
What is data type long in c?
How can I send mail from within a c program?
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none
hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell
Is c a great language, or what?
What is the difference between printf and scanf )?
What is function definition in c?
Can i use “int” data type to store the value 32768? Why?