/* Show approximation in floating-point operations Emad Arasteh October 10, 2019 */ #include int main() { float r = 1.2; float R = 4.7; float pi = 3.14159, eps = 0.0001; float x = 0, y = 0, diff = 0; x = pi * R * R - pi * r * r; y = pi * (R * R - r * r); diff = x - y; if (x == y) { printf("x and y are equal! \n"); } if (x != y) { printf("x and y are not equal! \n"); } /* abs(diff) < eps */ if (diff < eps && diff > -eps) { printf("x and y are approximately equal! \n"); } /* abs(diff) > eps */ if (!(diff < eps && diff > -eps)) { printf("x and y are not approximately equal! \n"); } printf("The value of x is %f \n", x); printf("The value of y is %f \n", y); return 0; }