Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Quadratic Equation
//g++ 7.4.0 //creator: John R Hubbard, University of Richmond #include <iostream> #include <cmath> using namespace std; int main () { float a,b,c; cout <<" Enter coefficients of quadratic equation:\n"; cin>>a>>b>>c; if(a==0){ cout<<"This is not a quadratic equation: a==0\n"; return 0; } cout<<"The equation is: "<<a<<"x*x + "<<b<<"x + "<<c<<" = 0\n"; double d, x1,x2; d=b*b - 4*a*c; if(d<0){ cout <<"This equation has no real solutions: d<0\n"; return 0; } x1=(-b + sqrt(d))/(2*a); x2= (-b - sqrt(d))/(2*a); cout <<"The solutions are: "<<x1<<","<<x2<<endl; return 0; }
run
|
edit
|
history
|
help
0
Count of factors
matrix2
staticfun
integerDivision
Proga1
Valuing Fixed Income Investments
point to a rvalue
Continuous Sub Set with given sum
Test 12(2021)
CPP - Ex 5