Problem in understanding the code execution? | SoloLearn: Learn to code for FREE!

+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; }

1/17/2021 2:30:41 PM

Ayush Jain

2 Answers

New Answer

+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.

+2

Aaron Eberhardt Thank u.....😊.....I understood!