How to write a C Program 0.1 + 0.2 != 0.3 Solved in C Programming Language ?
Solution For C Program :
//C Program 0.1 + 0.2 != 0.3 Solved.
#include <stdio.h>
/*
a == b
a - b == 0
0.1 + 0.2 == 0.3
(X) (0.1 + 0.2) - 0.3 == 0
(O) -0.00000001 < (0.1 + 0.2) - 0.3 < 0.00000001
*/
int main(){
double a = 0.1, b = 0.2;
printf("a + b = %lf\n", a+b);
if( (a + b) - 0.3 < 0.00000001 &&
(a + b) - 0.3 > -0.00000001 ){
printf(":)");
}
else{
printf(":(");
}
return 0;
}