/* Quadratic Equation*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d;
float r1,r2,s;
printf("enter a,b,c");
scanf("%d%d%d",&a,&b,&c);
d=b*b-(4*a*c);
s=sqrt(d);
if(d>=0)
{
r1=(-b+s)/(2*a);
r2=(-b-s)/(2*a);
if(r1==r2)
{
printf("the roots are real and equal\n");
printf("the root is %5.3f\n",r1);
}
else
printf("the roots are real and distinct\n");
printf("the roots are %5.3f and %5.3f\n",r1,r2);
}
else
printf("imaginary roots\n");
}
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d;
float r1,r2,s;
printf("enter a,b,c");
scanf("%d%d%d",&a,&b,&c);
d=b*b-(4*a*c);
s=sqrt(d);
if(d>=0)
{
r1=(-b+s)/(2*a);
r2=(-b-s)/(2*a);
if(r1==r2)
{
printf("the roots are real and equal\n");
printf("the root is %5.3f\n",r1);
}
else
printf("the roots are real and distinct\n");
printf("the roots are %5.3f and %5.3f\n",r1,r2);
}
else
printf("imaginary roots\n");
}
No comments:
Post a Comment