+ 1

Problem in understanding the code execution?

From code output why hello is not printed instead of hi...? https://code.sololearn.com/cPlyxS27TtNx/?ref=app #include <stdio.h> int main() { float a = 0.7; if(0.7>a){ printf("hi"); }else{ printf("hello"); } return 0; }

17th Jan 2021, 2:30 PM
Ayush Jain
Ayush Jain - avatar
2 Réponses
+ 2
Float numbers aren't perfectly accurate but are rounded in order to store the number inside 32 bit. Therefore you should never rely on exact float values but always tolerate a small offset.
17th Jan 2021, 2:46 PM
Aaron Eberhardt
Aaron Eberhardt - avatar
+ 2
Aaron Eberhardt Thank u.....😊.....I understood!
17th Jan 2021, 2:58 PM
Ayush Jain
Ayush Jain - avatar