Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include using namespace std; int main() { double a, b, c, x1, x2, discriminant, real, imaginary; cout < < Enter coefficients a, b and

#include #include using namespace std;

int main() {

double a, b, c, x1, x2, discriminant, real, imaginary;

cout << "Enter coefficients a, b and c: "; cin >> a >> b >> c; discriminant = b * b - 4 * a * c; if (a == 0) { cout << "The equation is not quadratic" << endl; return 0; }

if (discriminant > 0) { x1 = (-b + sqrt(discriminant)) / (2 * a); x2 = (-b - sqrt(discriminant)) / (2 * a); cout << "Roots are real." << endl; cout << "x1 = " << x1 << endl; cout << "x2 = " << x2 << endl; }

else if (discriminant < 0) { real = -b / (2 * a); imaginary = sqrt(-discriminant) / (2 * a); cout << "Roots are complex." << endl; cout << "x1 = " << real << "+" << imaginary << "i" << endl; cout << "x2 = " << real << "-" << imaginary << "i" << endl; } return 0; }

After printing the roots, query the user if he/she wishes to compute the roots again for another set of coefficients.

I don't know how to query the user to if he /she wishes to compute roots again so please help. just add a few line code to the above code for the user to query if he/she want to compute roots again. thanks.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

=+ b. The president restricts the import of foreign cars.

Answered: 1 week ago