#include <iostream>
#include <math.h>
using namespace std;
int main() {
// Your code goes here
float a, b, c, det, x1, x2;
cout << "Enter the quadratic equation in the form of ax2 + bx + c" << endl;
cout << "Enter the values of the a, b, and c: ";
cin >> a >> b >> c;
if(a == 0){
cout << "The equation is not quadratic as the value of a can't be zero" << endl;
return 1;
}
det = (b*b) - (4*a*c);
cout << "The determinant of the equation is: " << det << endl;
if(det > 0){
x1 = (-b + sqrt(det))/(2*a);
x2 = (-b - sqrt(det))/(2*a);
cout << "The roots of the equation are real and unequal: " << x1 << " and " << x2 << endl;
}
else if (det == 0)
{
x1 = -b / (2 * a);
cout << "The roots of the equation are real and equal: " << x1 << " and " << x1 << endl;
}
else{
cout << "The roots of the equation are imaginary" << endl;
}
return 0;
}
To embed this program on your website, copy the following code and paste it into your website's HTML: