// prg7
#include<iostream.h>
#include<math.h>
main()
{
float a,b,c,d,r1,r2;
cout<<"Enter a b and c \n";
cin>>a>>b>>c;
d=b*b-4*a*c;
if(d==0)
{
Cout<<"Roots are equal\n";
r1=-b/(2*a);
r2=r1;
cout<<"R1=R2="<<r1;
}
else
if(d>0)
{
cout<<"Roots are different\n";
r1=(-b+sqrt(d))/(2*a);
r2=(-b-sqrt(d))/(2*a);
cout<<"Root1="<<r1;
cout<<"Root2="<<r2;
}
else
cout<<"Complex number \n";
}
#include<iostream.h>
#include<math.h>
main()
{
float a,b,c,d,r1,r2;
cout<<"Enter a b and c \n";
cin>>a>>b>>c;
d=b*b-4*a*c;
if(d==0)
{
Cout<<"Roots are equal\n";
r1=-b/(2*a);
r2=r1;
cout<<"R1=R2="<<r1;
}
else
if(d>0)
{
cout<<"Roots are different\n";
r1=(-b+sqrt(d))/(2*a);
r2=(-b-sqrt(d))/(2*a);
cout<<"Root1="<<r1;
cout<<"Root2="<<r2;
}
else
cout<<"Complex number \n";
}
No comments:
Post a Comment