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


Please Help Members By Posting Answers For Below Questions

I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...

9645


What does. int *x[](); means ?

624


What is bin sh c?

570


How can you return multiple values from a function?

620


What is the use of static variable in c?

587






What is "Duff's Device"?

691


Lists the benefits of c programming language?

578


How do you define structure?

553


Difference between Function to pointer and pointer to function

621


What is #define?

566


This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory

717


Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.

1609


find the sum of two matrices and WAP for it.

620


Define recursion in c.

690


What is the difference between struct and union in C?

553