#include <iostream>
#include <math.h>
using namespace std;
int main()
{ double a,b,c,d;
cout <<"The roots of a quadratic equation ax² + bx + c = 0\n";
cout <<"Input a, b, and c\n";
cin >> a >> b >> c;
cout <<"The roots of a quadratic equation: " <<a<<"x² + "<<b<<"x + "<<c<<" = 0\n";
d=b*b-4*a*c;
if (d<0) cout <<"No solutions\n";
else if (d==0) cout << "x= "<< -b/(2*a);
else cout <<"x₁=" << (-b+sqrt(d))/(2*a)<<"\n" <<"x₂=" << (-b - sqrt(d))/(2*a)<<"\n";
return 0;
}
No comments:
Post a Comment