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 Jain2 Answers
New AnswerFloat 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.
SoloLearn Inc.
4 Embarcadero Center, Suite 1455Send us a message