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
How can you increase the allowable number of simultaneously open files?
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
What is string constants?
Explain what are multidimensional arrays?
Draw a flowchart to produce a printed list of all the students over the age of 20 in a class .The input records contains the name and age of students. Assume a sentinel value of 99 for the age field of the trailer record
Explain the difference between malloc() and calloc() in c?
What is default value of global variable in c?
process by which one bit patten in to another by bit wise operation is? (a) masking, (b) pruning, (c) biting, (d) chopping,
In C, What is the #line used for?
Why structure is used in c?
What are the different types of control structures?
how to write optimum code to divide a 50 digit number with a 25 digit number??
What is c value paradox explain?
What is the advantage of using #define to declare a constant?
What is the most efficient way to store flag values?