#include #include int main() { double a, b, c, term, a2, root1, root2; // a b and c are the coefficients of the terms // a*x**2+b*x+c // find the roots of the quadratic, root1 and // root2 printf(" Type in the coefficients a, b and c\n"); scanf("%lf %lf %lf", &a, &b, &c); printf(" a = %lf\n",a); printf(" b = %lf\n",b); printf(" c = %lf\n",c); term = b*b - 4.*a*c; a2 = a*2.; // if term < 0, roots are complex // if term = 0, roots are equal // if term > 0, roots are double and different if (term<0.0) { printf(" roots are complex\n"); } else if (term>0.0) { term = sqrt(term); root1 = (-b+term)/a2; root2 = (-b-term)/a2; printf(" roots are %lf %lf\n", root1, root2); } else { root1 = -b/a2; printf(" roots are equal, at %lf\n", root1); } return(0); }