+ 6
It showing output hi. How's it?
float a = 0.7; if(0.7 > a) printf("Hi\n"); else printf("Hello\n");
3 odpowiedzi
+ 7
Because you need to define 0.7 in your if statement as a float
(write 0.7f instead of 0.7)
If you don't include the "f" the compiler sees the value as a double instead of a float. Double values have more precision than float values and 0.7 as a double will be greater then as a float.
+ 5
In smaller programs where memory is not much of a concern, perhaps it's better to use doubles rather than floats for reasons such as this?
+ 2
https://www.sololearn.com/discuss/1801451/?ref=app
Check this thread...