This program uses quadratic formula to find the roots of the quadratic equations.
#include<iostream>
#include<cmath>
using namespace std;
int main(){
double x1,x2,x3;
double dis,r1,r2;
cout<<"Enter the coefficients "<<endl;
cout<<"x1 : ";
cin>>x1;
cout<<"x2 : ";
cin>>x2;
cout<<"x3 : ";
cin>>x3;
dis = x2*x2-4*x1*x3;
if(dis>0){
r1 = (-x2+sqrt(dis))/(2*x1);
r2 = (-x2-sqrt(dis))/(2*x1);
cout<<"r1 = "<<r1<<endl;
cout<<"r2 = "<<r2<<endl;
}
else if(dis==0){
r1 = -x2/(2*x1);
r2 = r1;
cout<<"r1 = r2 = "<<r1<<endl;
}
else{
cout<<"Negative Roots"<<endl;
}
return 0;
}


