0
int main(){ float a = 0.7; if(0.7>a) printf("hi"); else printf("bye "); } output: hi <---can anyone explain the above code.
4 Antworten
+ 1
it's because you're comparing a double with a float. number literals are automatically treated as doubles. a double has more memory allocated than float.
if you do float b=0.7 and then compare it with a, you would get the desired results.
0
when a=0.7, the output is hi. but here the condition is 0.7>a. then how it is print hi as a output.
- 1
You're checking if 0.7 is greater than a // 0.7>a // 0.7>0.7
Which is false or not true as they have same value.
So the output is hi