+ 2
#include <stdio.h> void main() { float x = 0.1; if (x == 0.1) printf("Sanfoundry"); else printf("Advanced C Classes"); }
The o/p is "Advanced c classes " How ??
3 Respuestas
+ 5
𝔸𝕒𝕗𝕥𝕒𝕓 𝕂𝕙𝕒𝕟
What ✳AsterisK✳ said is right and if you desire to get the output as "Sanfoundry", please make sure the condition inside if is "x==0.1f"
#include <stdio.h>
int main()
{
float x = 0.1;
if (x == 0.1f)
printf("Sanfoundry");
else
printf("Advanced C Classes");
return 0;
}
+ 3
x is float while just writing 0.1 is a double, hence the reason precision make em different
0
I got it.
Thanks both of you.🙂