Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  solving
Language: C/C++
Code:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{int a,b,c,d,a1,b1,b2;
cout<<"enter a:";
cin>>a;
cout<<"enter b:";
cin>>b;
cout<<"enter c:";
cin>>c;
d=(b*b)-(4*a*c);
a1=-b/2a;
if (d<0)
{cout<<"the roots are imaginary";
b1=sqrt(-d)/2*a;
cout<<"the first root is"<<a1<<"+"<<"i"<<b1;
cout<<"the second root is"<<a1<<"-"<<"i"<<b1;
}
else if(d==0)
{cout<<"the root is real and unique";
cout<<"the root is:"<<a1;
}
else
{cout<<"the root is real and distinct";
b2=sqrt(d)/2*a;
cout<<"the first root is"<<a1<<"+"<<b2;
cout<<"the second root is"<<a1<<"-"<<b2;
}
}          
Comments: