C + + program to solve quadratic polynomials
# include <iostream.h>
# include <math.h>
stdlib.h
int main ()
{
float a, b, c, rta1, rta2, lin, base, root, raiz2, img, x;
court <<"\ n ax ^ 2 + bx + c = 0" <<endl;
court <<endl;
court <<"Enter the value to";
cin>> a;
court <<endl;
court <<"Enter the value of b:";
cin>> b;
court <<endl;
court <<"Enter the value of c:";
cin>> c;
court <<endl;
system ("cls");
court <<endl;
court <<a <<"x ^ 2 +" <<b <<"x +" <<c <<"= 0" <<endl;
court <<endl;
if (a! = 0)
{
base = ((pow (b, 2)) - (4 * a * c));
if (base> = 0)
{
root = pow (base, 0.5);
rta1 = (-b + (root)) / (2 * a);
rta2 = (-b-(root)) / (2 * a);
court <<"The first root is:" <<rta1 <<endl;
court <<endl;
court <<"The second root is:" <<rta2 <<endl;
court <<endl;
}
else
{
img = base * (-1);
root = (pow (img, 0,5)) / (2 * a);
raiz2 =- (pow (img, 0,5)) / (2 * a);
rta1 =- b / (2 * a);
court <<"The first imaginary root is" <<rta1 <<"i" <<root <<endl;
court <<"The second imaginary root is" <<rta1 <<"i" <<raiz2 <<endl;
court <<endl;
}
}
else
{
if ((a == 0) & & (c == 0))
{
x = 0 / b;
court <<"The root is" <<x <<endl;
}
else if (b> 0)
{
lin = (-c / b);
court <<"The value of the root is:" <<lin;
court <<endl;
}
else
{
court <<"You just pick a point" <<c;
court <<endl;
}
}
system ("PAUSE");
return 0;
}
# include <math.h>
stdlib.h
int main ()
{
float a, b, c, rta1, rta2, lin, base, root, raiz2, img, x;
court <<"\ n ax ^ 2 + bx + c = 0" <<endl;
court <<endl;
court <<"Enter the value to";
cin>> a;
court <<endl;
court <<"Enter the value of b:";
cin>> b;
court <<endl;
court <<"Enter the value of c:";
cin>> c;
court <<endl;
system ("cls");
court <<endl;
court <<a <<"x ^ 2 +" <<b <<"x +" <<c <<"= 0" <<endl;
court <<endl;
if (a! = 0)
{
base = ((pow (b, 2)) - (4 * a * c));
if (base> = 0)
{
root = pow (base, 0.5);
rta1 = (-b + (root)) / (2 * a);
rta2 = (-b-(root)) / (2 * a);
court <<"The first root is:" <<rta1 <<endl;
court <<endl;
court <<"The second root is:" <<rta2 <<endl;
court <<endl;
}
else
{
img = base * (-1);
root = (pow (img, 0,5)) / (2 * a);
raiz2 =- (pow (img, 0,5)) / (2 * a);
rta1 =- b / (2 * a);
court <<"The first imaginary root is" <<rta1 <<"i" <<root <<endl;
court <<"The second imaginary root is" <<rta1 <<"i" <<raiz2 <<endl;
court <<endl;
}
}
else
{
if ((a == 0) & & (c == 0))
{
x = 0 / b;
court <<"The root is" <<x <<endl;
}
else if (b> 0)
{
lin = (-c / b);
court <<"The value of the root is:" <<lin;
court <<endl;
}
else
{
court <<"You just pick a point" <<c;
court <<endl;
}
}
system ("PAUSE");
return 0;
}
0 Response to C + + program to solve quadratic polynomials
Post a Comment