Quadratic Equation CPP Project
Quadratic Equation CPP Project
int main() {
discriminant = b * b - 4 * a * c;
if (discriminant > 0) {
} else if (discriminant == 0) {
} else {
cout << "Root 1 = " << realPart << " + " <<
imaginaryPart << "i\n";
cout << "Root 2 = " << realPart << " - " <<
imaginaryPart << "i\n";
return 0;}
5. Output
Given Quadratic Equation: 6x² + 11x - 35 = 0
Roots are real and different.
Root 1 = 1.66667
Root 2 = -3.5
So, the roots of the equation 6x² + 11x − 35 = 0 are:
- x = 5/3 (≈1.67)
- x = -3.5
6. Conclusion
This project demonstrates how quadratic equations can
be solved easily with C++. By using the discriminant
and the quadratic formula, we computed the exact
roots. This approach can be extended to handle any
type of quadratic equation efficiently.