bhaskara 27s formula

Solutions on MaxInterview for bhaskara 27s formula by the best coders in the world

showing results for - "bhaskara 27s formula"
Lavana
14 Jul 2019
1// bhaskara's formula in c
2#include <stdio.h>
3#include <math.h>
4int main()
5{
6  double a, b, c, r1, r2;
7  scanf("%lf %lf %lf", &a, &b, &c);
8  r1 = (-b + sqrt(pow(b, 2) - (4 * a * c))) / (2 * a);
9  r2 = (-b - sqrt(pow(b, 2) - (4 * a * c))) / (2 * a);
10  if ((int)a == 0 || b < c)
11  {
12    printf("impossible to calculate\n");
13  }
14  else
15  {
16
17    printf("R1 = %0.5lf\n", r1);
18    printf("R2 = %0.5lf\n", r2);
19  }
20
21  return 0;
22}
similar questions
bhaskara 27s formula in c