Question: #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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!