+ 4

Why it print else statement rathar than if ?

float f1 = 0.1; if (f1 == 0.1) printf("Equal"); else printf("Not Equal");

5th Jan 2019, 11:01 AM
Jagjot Mann
Jagjot Mann  - avatar
3 Answers
+ 8
Write : if (f1 == 0.1f) Then, you're sure the compiler see 0.1 as a float. In fact, f1=0.1000 and that's different from 0.1, you see ?
5th Jan 2019, 11:12 AM
Théophile
Théophile - avatar
+ 2
You're welcome ☺️!
5th Jan 2019, 11:23 AM
Théophile
Théophile - avatar
+ 1
Yes it worked. Thanks a lot Sir 🤗
5th Jan 2019, 11:20 AM
Jagjot Mann
Jagjot Mann  - avatar