0

why does it print "Good" when we input s=3.6????

#include<stdio.h> int main(){ float s; scanf("%f",&s); if(s>=3.6) printf("Excelent"); else printf("Good"); return 0; }

20th Dec 2021, 12:45 PM
Hảo Nguyễn Thiên
Hảo Nguyễn Thiên - avatar
2 Respuestas
+ 4
Float precision Read this article about comparing float value in c language. https://www.geeksforgeeks.org/comparison-float-value-c/
20th Dec 2021, 12:57 PM
Anya
Anya - avatar
+ 2
3.6 float is 3.59999... And you're comparing it to 3.6 double (3.60000...)
20th Dec 2021, 12:54 PM
Angelo
Angelo - avatar