View Code of Problem 42

#include<stdio.h>
#include<math.h>
double f(double a,double b,double c);
double g(double a,double b,double c);
int main()
{
   double a,b,c;
   double x1,x2,t;
    scanf("%lf%lf%lf",&a,&b,&c);
    x1=f(a,b,c);
    x2=g(a,b,c);
   if(x1<x2)
{t=x1;x1=x2;x2=t;}
printf("%.2lf %.2lf\n",x1,x2);
return 0;
}
double f(double a,double b,double c)
{
double x1;
x1=(-b+sqrt(pow(b,2)-4*a*c))/(2*a);
return x1;
}
double g(double a,double b,double c)
{
double x2;
x2=(-b-sqrt(pow(b,2)-4*a*c))/(2*a);
return x2;
}

Double click to view unformatted code.


Back to problem 42