+ 1
#include <stdio.h> int main() { float a=0.7; if(0.7>a) printf("hi"); else printf("hello"); }
Why the output is hi
3 Réponses
+ 9
Rohit Ahuja
It's because a is 0.69999999998 in it's floating representation.
And normal 0.7 is an double precision value, So the comparison between float and double leads to type promotion and in that case a is less than 0.7 which is double. So the output will be printed as hi
this thread will give you some detailed answer about the precision value types
https://www.sololearn.com/Discuss/796595/?ref=app
0
Thanks GAWEN
0
How can we know that a=0.69999999998 ???