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
sejmie
Updated Linked Lists - 5/10/2017 V4.0
Sorting sort function stl in c++
C++
Dar
Interest Compounding
cppPyPoly
alma
Elevator
BubbleDouble