//pgm to find the roots of a quadratic equation
#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,d,x1,x2,p;
clrscr();
cout<<"enter the values of a,b,c"<<endl;
cin>>a>>b>>c;
d=(b*b-4*a*c);
if(d>0)
{
p=sqrt(d);
x1=(-b+p)/2*a;
x2=(-b-p)/2*a;
cout<<x1<<endl<<x2;
}
if(d==0)
{
x1=-b/2*a;
x2=x1;
cout<<x1<<endl<<x2;
}
if(d<0)
{
cout<<"roots are imaginary";
}
getch();
}
Please Click on ADS!!
Please Click on the above ads given by GOOGLE , so that I can maintain my blog!!
Tuesday, August 31, 2010
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment