Download C++ Compiler here : bakhtshirensoft.blogspot.my/2015/11/dev-c-511.html
You can get code of this C++ here ; DOWNLOAD C++ code
For a quadratic equation ax2+bx+c = 0 (where a, b and c are coefficients), it's roots is given by following the formula.
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<cstring>
using namespace std;
int main()
{
double a,b,c,x1,x2;
char x;
cout<<"enter the value of a=";
cin>>a;
cout<<"enter the value of b=";
cin>>b;
cout<<"enter the value of c=";
cin>>c;
cout<<"the quadratic equation is"<<a;
cout<<"*x*x+"<<b;
cout<<"*x+"<<c<<endl;
if
(a==0 && b==0)
cout<<"not a valid equation";
if
(a==0 && b!=0)
{
x1=-(c/b);
cout<<endl;
cout<<"root="<<x1;
cout<<endl;
}
if ((b*b-4*a*c)>0)
{
x2=(b*b)-(4*a*c);
x1=-b+sqrt(x2);
cout<<"root="<<x1<<endl;
}
if ((b*b-4*a*c)<0)
{
cout<<"not a real root"<<endl;
}
system("pause");
return 0;
}
The Output
enter the value of a=4
enter the value of b=5
enter the value of c=1
the quadratic equation is4*x*x+5*x+1
root=-2