Code:
#include <iostream> #include <cmath> using namespace std; int main (int argc, char** argv) { double a=0.0; double b=0.0; double c=0.0; double num=0.0; cout <<"Given this form of equation: aX2 + bX + c = 0"<<endl; cout <<"Input the value of a (the coefficient of X2)"<<endl; cin>>a; cout <<"Input the value of b (the coefficient of X)"<<endl; cin>>b; cout <<"Input the value of c (the constant value)"<<endl; cin>>c; cout<<"Your equation is the following"<<endl; cout<<a<<"X2 + "<<b<<"X + "<<c<<" = 0"<<endl; num= pow(b,2)-(4*a*c); if (num=0) { cout<<"This equation has a single (repeated) root."<<endl; } if (num<0) { cout<<"This equation has two complex roots."<<endl; } if (num>0) { cout<<"This equation has two real roots."<<endl; } return 0; }
Comment