main()
{
float f=0.7;
if(0.7>f)
printf("Hi");
else
printf("Hello"):
}
When I compile this program output comes out to be Hi
.
Can someone please explain the scenerio how 0.7>0.7
is true
? Is this due to fact that 0.7
used in if statement is a double
and f
is a float
?
Even if it is double
still its value is 0.7
difference created is just that in case of double
it is stored in 8 byte while in case of float
it is stored in 4 byte. But I think it does not matters how big is your container when the value stored in container is equal. So 0.7
can never be greater than f. So according to me it should result in Hello
. then why Hi
is the output?