hi this is Fatima..!! i have started C++ programming few days back..!!
i am given an assignment fer homewrk.In the prob i have to take the sqr root but i dun knw how to take square root.
the code is
Code:
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int roots1,roots,a,b,c;
cout<<"Enter value of a=";
cin>>a;
cout<<"Enter value of b=";
cin>>b;
cout<<"Enter value of c=";
cin>>c;
if (b*b- 4*a*c==0)
{
cout<<"Roots are single,equal";
}
else if (b*b-4*a*c>0)
{
cout<<"Equation has two real roots";
}
else if (b*b-4*a*c<0)
{
cout<<"Equation has two complex roots";
}
else if (b*b-4*a*c>=0)
{
roots=-b+sqrt(b*b-4*a*c)/2*a;
roots1=-b-sqrt(b*b-4*a*c)/2*a;
cout<<"The roots are"<<roots<<roots1<<endl;
}
getch();
}
in the last part if b^2-4ac is greater than and equal to zero then i have to take square root of it..and display the roots but i dun knw how to..!!