Quadratic Equations:
A quadratic equation is a polynomial equation of the second degree.The general form is
where x represents a variable or an unknown, and a, b, and c are constants with a ≠ 0.The roots are given by the quadratic formula:
CODE:
A quadratic equation is a polynomial equation of the second degree.The general form is
where x represents a variable or an unknown, and a, b, and c are constants with a ≠ 0.The roots are given by the quadratic formula:CODE:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
float a,b,c,x1,x2;
cout<<"Enter Values a,b,c for the Equation aX^2 + bX + c= 0 : ";
cin>>a>>b>>c;
float d=(b*b)-(4*a*c);
if(d==0)
{
x1=x2=(-b)/(2*a);
cout<<"Roots are Real and Equal x1=x2 :"<<x1;
}
else if(d>0)
{
x1=((-b)+sqrt(d))/(2*a);
x2=((-b)-sqrt(d))/(2*a);
cout<<"Roots of the equation are x1="<<x1<<"/n x2="<<x2;
}
else
{
cout<<"Roots are Imaginary";
}
getch();
}
For Further Reading,

0 comments:
Post a Comment