How to write a C Program double, float equal in C Programming Language ?
Solution For C Program :
/*C Program double, float equal.*/
#include <stdio.h>
int main(){
double a = 0.1;
double b = 0.2;
/*
float, double: ==
(x) a == b => a - b == 0
(o) -0.0000001 < a - b < 0.0000001
*/
double compare = (a+b) - 0.3;
if( compare < 0.0000001 && compare > -0.0000001 ){
printf(":)");
}
else{
printf(":(");
}
return 0;
}
Program related to C Programming Language :
- C Program Array Index Example
- C Program String - Alphabet Count Example
- C Program Character toupper() Example
- C Program Array Example: Average
- C Program Array Example: Reverse
- C Program if - while - for Example
- C Program Switch - Case Example
- C Program 0.1 + 0.2 != 0.3 Solved
- C Program if - else if - else Example
- C Program typedef Example
- C Program scanf & gets Example
- C Program Friend & Operator: Point2D Example
- C Program Friend & Operator: Vector Example
- C Program Recursion Example
- C Program File Input & Output Example
- C Program Structure Example-2
- C Program Structure Example
- C Program Pointer Example
- C Program Function Example
- C Program String Example
- C Program String Count Example
- C Program String Example
- C Program Character Example
- C Program Sort Example
- C Program sizeof & memcpy Example
- C Program Array Example
- C Program to Array
- C Program print fill zero & mod/div
- C Program Double, Float Equal
- C Program nested for
- C Program for
- C Program if
- C Program System
- C Program Operation
- C Program to printf & scanf
- Example C Program Cuda Malloc
- C Program Side Length
Learn More :
Equal
Double