1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | //cpp program to solvee quodratic equation. //written by lucky ibitubo #include<iostream> #include<cmath> using namespace std; int main() { //variable diclaration float a,b,c,b1,b2,x1,x2,determinant,squareroot,deniminator; //input statement cout<<"enter values for a,b,c."<<endl; cin>>a>>b>>c; //calculation determinant=(b*b)+(4*a*c); squareroot=sqrt(determinant); deniminator=(2*a); b1=(-b+squareroot)/deniminator; b2=(-b-squareroot)/deniminator; //conditional statements if(determinant<0){ cout<<"No Sqrt of a -sign"<<endl; } else if(determinant>0){ x1=b1; cout<<"X1 = "<<x1<<endl; x2=b2; cout<<"X2 = "<<x2<<endl; } return 0; } |
Home / Uncategories / quodratic formula, a cpp program that accepts input from user and gives the valid output.
- Blogger Comment
- Facebook Comment
Subscribe to:
Post Comments
(
Atom
)
Powered by Blogger.
0 comments:
Post a Comment