fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main(void) {
  5. float b = 2.0f, c = -0.001f;
  6. float x1, x2, x3;
  7.  
  8. x1 = (-b + sqrtf(b * b - 4 * c)) / 2;
  9.  
  10. x2 = -2 * c / (b + sqrtf(b * b - 4 * c));
  11.  
  12. x3 = -c / b * (1 + c / (b * b));
  13.  
  14. printf("x1 = %e\nx2 = %e\nx3 = %e\n", x1, x2, x3);
  15.  
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 4240KB
stdin
Standard input is empty
stdout
x1 = 4.998446e-04
x2 = 4.998751e-04
x3 = 4.998751e-04