so how would i implement the outputs and conditions like i said above into my code below???
changed my code:
Code:// Quadratic Equation.cpp : main project file. #include <cmath> // defines the sqrt() function #include <iostream> using namespace std; int main() { // implements the quadratic formula float a, b, c; cout << "Enter the coefficients of a quadratic equation:" << endl; cout << "a: "; cin >> a; cout << "b: "; cin >> b; cout << "c: "; cin >> c; cout << "The roots of " << a << "*x*x + " << b << "*x + " << c << " = 0" << endl; float d = b*b - 4*a*c; // discriminant float sqrtd = sqrt(d); float x1 = (-b + sqrtd)/(2*a); float x2 = (-b - sqrtd)/(2*a); cout << "are:" << endl; cout << "x1 = " << x1 << endl; cout << "x2 = " << x2 << endl; } :check:




Reply With Quote