0
an eqn of the form ax²+bx+c=0 known as quadratic equation . the values of x that satisfy the eqn are known as roots of the eqn
2 odpowiedzi
+ 1
#include <iostream>
#include <cmath>
using namespace std;
int main() {
    double a ,b ,c;
    double x1, x2;
    double det;
    
    cout<<"please enter a, b and c"<<endl;
    cin>>a>>b>>c;
    det=b*b-4*a*c;
    
    if(det>0)
{
x1=(-b+sqrt(det))/(2*a);
x2=(-b-sqrt(det))/(2*a);     cout<<"x1 = "<<x1<<endl;
cout<<"x2 = "<<x2<<endl;
}
    else if(det==0)
{    
x1=(-b+sqrt(det))/(2*a);
cout<<"x1 = x2 = "<<x1;
}
    return 0;
}
0
In the header, include <cmath>, 
then you can use sqrt() function to get quareroot of a number. Like so: sqrt(4) returns 2. 
I won't do comments on this as posting here is a right pain, if there are any questions on this, mail me andresmarivent@yahoo.com cheers  



