C++ Program to Find roots are imaginary

C++ Program to Find roots are imaginary


#include
#include
#include
void main()
{
int a,b,c;
clrscr();
cout<<"enter the values of a,b,c";
cin>>a>>b>>c;
int d=(b*b)-4ac ;
if (d<0)
cout<<"\n\t roots are imaginary";
if(d==0)
{
float x;
x=-b/2*a;
cout<<"\n\t X="< < x;
}
if(d>0)
{
float x1,x2;
x1=-b+sqrt(d)/2*a;
x2=-b-sqrt(d)/2*a;
cout<<"\n\t x1="< < x1;
cout<<"\n\t x2="< < x2;
}
getch();
}





No comments:

Post a Comment