#include<iostream.h>
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float a,b,c,d,e,x,r,t;
int D,z,f;
cout<<"Enter a= ";
cin>>a;
cout<<"enter b=";
cin>>b;
cout<<"Enter c=";
cin>>c;
D=b*b-4*a*c;
f=D>0?1:(D==0?2:(D<0?3:4));
switch (f)
{ case 1:
x=(-b+sqrt(D))/(2*a);
r=(-b-sqrt(D))/(2*a);
cout<<"Roots of the Equation are Real"<<"\n";
cout<<"Root 1 = "<<x<<"\n";
cout<<"Root 2 = "<<r;
break;
case 2:
x=(-b)/(2*a);
cout<<"Root of the Equation are Real and Equal "<<"\n";
cout<<"Root = "<<x;
break;
case 3:
cout<<"Roots are Imaginary";
break;
}
getch();
}
#include<conio.h>
#include<math.h>
void main()
{
clrscr();
float a,b,c,d,e,x,r,t;
int D,z,f;
cout<<"Enter a= ";
cin>>a;
cout<<"enter b=";
cin>>b;
cout<<"Enter c=";
cin>>c;
D=b*b-4*a*c;
f=D>0?1:(D==0?2:(D<0?3:4));
switch (f)
{ case 1:
x=(-b+sqrt(D))/(2*a);
r=(-b-sqrt(D))/(2*a);
cout<<"Roots of the Equation are Real"<<"\n";
cout<<"Root 1 = "<<x<<"\n";
cout<<"Root 2 = "<<r;
break;
case 2:
x=(-b)/(2*a);
cout<<"Root of the Equation are Real and Equal "<<"\n";
cout<<"Root = "<<x;
break;
case 3:
cout<<"Roots are Imaginary";
break;
}
getch();
}
No comments:
Post a Comment