+ 3
Please explain this code ?
float a=0.7; if(0.7>a) printf("Hi\n"); else printf ("Hello\n");
4 Answers
+ 12
In if statement you are comparing a double precision floating point to a single precision floating point. 0.7 (double)approximate value is greater than 0.7f
For more explanation you can refer :
https://www.quora.com/include-stdio-h-void-main-float-a-0-7-if-a-0-7-printf-1-else-printf-2-The-output-of-the-above-program-is-1-How
+ 3
Thanks for your answers
+ 2
What part don't you understand? It's basic logic... if this condition is true, do this, if not, do that