I was going through the same question in two different languages. Got different results. Need help to understand why this is happening?
I wrote the same code in python and got a different result than what was expected from C.
Code 1:
{
float f = 0.1;
if (f == 0.1)
printf("YES\n");
else
printf("NO\n");
return 0;
}
Code 2:
f = float()
f = 0.1
if (f == 0.1):
print("YES")
else:
print("NO")
Both must give the same output as NO. But only C is giving the expected output while Python is giving the output as YES.