View Code of Problem 42

#include<stdio.h>
#include<math.h>
int main(){
  double a,b,c,d,c1,c2;
  scanf("%lf %lf %lf",&a,&b,&c);
  d=b*b-4*a*c;
  if(d>=0){
    c1=(-b+sqrt(d))/(2*a);
    c1=(-b-sqrt(d))/(2*a);
    if(c1>=c2)
      printf("%.2lf %.2lf",c1,c2);
    else
      printf("%.2lf %.2lf",c2,c1);
    
  }
  else{
    printf("ERROR");
  }
  
  return 0;
}

Double click to view unformatted code.


Back to problem 42