Question

Create a QuadraticEquation application that gives the solution to any quadratic equation. The application should prompt...

Create a QuadraticEquation application that gives the solution to any quadratic equation. The application should prompt the user for values for a, b, and c (ax2 + bx + c = 0) and then display the roots, if any

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//you have not mentioned the language, i have done in c++, if you need in C,C#,Java, python, r, matlab,octave, scilab etc

//please comment

#include <iostream>

#include <math.h>

using namespace std;

int main()
{   
double a,b,c;
cout<<"enter value of a:";cin>>a;
cout<<"enter value of b:";cin>>b;
cout<<"enter value of c:";cin>>c;
  
double D=b*b-4*a*c;
if(D>=0)
{double root1= (-b+sqrt(D))/(2*a);
double root2= (-b-sqrt(D))/(2*a);
cout<<"roots are :"<<root1<<","<<root2;
}
else
{
cout<<"roots are: (-"<<b<<"+i sqrt("<<(-1*D)<<"))/"<<(2*a)<<",";
cout<<"(-"<<b<<"-i sqrt("<<(-1*D)<<"))/"<<(2*a)<<",";
}
return 0;
}

Add a comment
Know the answer?
Add Answer to:
Create a QuadraticEquation application that gives the solution to any quadratic equation. The application should prompt...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT