#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,b,c,d;
float r1,r2;
cout<<"Enter the values of a,b & c : ";
cin>>a>>b>>c;
d=(b*b)-(4*a*c);
if(d==0)
{
cout<<"Roots are real and equal ";
r1=r2=(-b)/(2*a);
cout<<r1<<" "<<r2;
}
else
if(d>0)
{
cout<<"Roots are real and unequal ";
r1=(-b+sqrt(d))/(2*a);
r1=(-b-sqrt(d))/(2*a);
}
else
cot<<"Roots are imaginary";
getch();
}
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
int a,b,c,d;
float r1,r2;
cout<<"Enter the values of a,b & c : ";
cin>>a>>b>>c;
d=(b*b)-(4*a*c);
if(d==0)
{
cout<<"Roots are real and equal ";
r1=r2=(-b)/(2*a);
cout<<r1<<" "<<r2;
}
else
if(d>0)
{
cout<<"Roots are real and unequal ";
r1=(-b+sqrt(d))/(2*a);
r1=(-b-sqrt(d))/(2*a);
}
else
cot<<"Roots are imaginary";
getch();
}
No comments:
Post a Comment