View Code of Problem 42

#include<stdio.h>
#include<math.h>
double f(double a,double b,double c)
{

    double s;
    s=(-b+sqrt(b*b-4*a*c))/2.0;
    return s;
}
double f1(double a,double b,double c)
{

    double s;
    s=(-b-sqrt(b*b-4*a*c))/2.0;
    return s;
}
int main()
{
    double a,b,c,x1,x2;
    scanf("%lf%lf%lf",&a,&b,&c);
    x1=f(a,b,c);
    x2=f1(a,b,c);
    double t;
    if(x1<x2) {t=x1;x1=x2;x2=t;}
    printf("%.2lf %.2lf\n",x1,x2);
    return 0;

}

Double click to view unformatted code.


Back to problem 42