Latest Posts:

quodratic formula, a cpp program that accepts input from user and gives the valid output.


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;
}
Share on Google Plus

About Lucky Ibitubo

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment

Powered by Blogger.