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
How can you determine the size of an allocated portion of memory?
Under what circumstances does a name clash occur?
Why static variable is used in c?
What is the use of f in c?
What is a sequential access file?
What is the explanation for cyclic nature of data types in c?
what do the 'c' and 'v' in argc and argv stand for?
How can you determine the maximum value that a numeric variable can hold?
Write a program to reverse a string.
What is the scope of global variable in c?
What is the modulus operator?
What is queue in c?
what is the height of tree if leaf node is at level 3. please explain
Why array is used in c?
Write a program to show the change in position of a cursor using c