bhaskara 27s formula in c

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

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