If condition Explain this program | SoloLearn: Learn to code for FREE!

0

If condition Explain this program

On this program output is Sachin but according to the if by condition is true because float value is equals to the f 1 so why it prints the else statement not the if condition statement why please explain a https://code.sololearn.com/cHuBKVN4UvpU/?ref=app

5/15/2020 2:42:44 AM

Sachin Saxena

4 Answers

New Answer

+12

Basically because float is not too precise. If you use a double, you will see that it prints the first condition.

+12

Sachin Saxena I just saw your issue, you missed the f at the end of the float. float f = 0.9f; if(f == 0.9f)...

0

so float is not worked on if condition

0

Ok thanks