A simple c++ code to solve a quadratic equation.

After include in first line there must be written "iostream" inside <>.
#include
#include<conio.h>
#include<math.h>
using namespace std;
int main()
{
int si;
float a,b,c,d,root1,root2,real,imaginary;
while(true)
{
cout<<"enter the serial number"<<endl;
cin>>si;
if(si==0)
{
break;
}
cout<<"enter the value of a"<<endl;
cin>>a;
cout<<"enter the value of b"<<endl;
cin>>b;
cout<<"enter the value of c"<<endl;
cin>>c;
d=bb-4ac;
if(d>0)
{
root1=(-b+sqrt(d))/(2a);
root2=(-b-sqrt(d))/(2a);
cout<<"the roots are real and different"<<endl;
cout<<"root1="<<root1<<endl;
cout<<"root2="<<root2<<endl;
}
else if(d<0)
{
real=-b/(2a);
imaginary=(sqrt(-d))/(2a);
cout<<"the roots are complex and different"<<endl;
cout<<"root1="<<real<<"+i"<<imaginary<<endl;
cout<<"root2="<<real<<"-i"<<imaginary<<endl;
}
else
{
root1=-b/(2a);
root2=root1;
cout<<"the roots are real and equal"<<endl;
cout<<"root1=root2="<<root1<<endl;
}
}
getch();
}
Leave A simple c++ code to solve a quadratic equation. to:
Read more #programming posts
Best Posts From steemibu351
We have not curated any of steemibu351's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From steemibu351
- It is high time for proper money management.
- Why we fall?
- A horrible game for Barcelona against Inter Milan.
- Yamaha RX-100: One of my most favourite motorcycle.
- Barca's new transfer window
- Food safety
- Manchester City and Halland's show against Nottingham Forrest.
- Our government is joking with our tea garden workers.
- Let's focus on Spanish La Liga
- What a big discrimination with tea workers in Bangladesh!