#include
#include
#include
template
void quad(temp a ,temp b ,temp c)
{
temp r1,r2,d;
d=b*b-(4*a*c);
if(d==0)
{
r1=(-b/(2*a));
cout<<"\n\nRoots are equal and real ->";
cout<<"\n\n r1=r2= "< }
else if(d>0)
{
cout<<"\n\nRoots are real and unequal ->";
r1=(-b+sqrt(d))/(2*a);
cout<<"\n\n r1= "< r2=(-b-sqrt(d))/(2*a);
cout<<"\n\n r2= "< }
else
{
cout<<"\n\nRoots are complex and imaginary ..."; }
}
void main()
{
clrscr();
float a,b,c; cout<<"\n\nEnter values of a ,b and c for eq. a*x^2+b*x+c=0: "; cout<<"\n\nEnter first value : "; cin>>a; cout<<"\n\nEnter second value : "; cin>>b; cout<<"\n\nEnter third value : "; cin>>c; quad(a,b,c); getch();
}
|
No feedbacks found. Be the first to respond and make money from revenue sharing program.
|