#include<math.h>
Author: Sanif S S
Site: theeduzone.blogspot.com
Email: sanifss@gmail.com#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int a,b,c;
float d,r1,r2;
printf("enter coefficients of equation\n");
scanf("%d %d %d",&a,&b,&c);
if(a==0)
{
printf("not possible");
}
else
{
d=((b*b)-(4*a*c));
if(d==0)
{
printf("roots are real and equal\n");
r1=((-b/(2*a)));
printf("r1=r2=%f",r1);
}
if(d>0)
{
printf("roots are real and distinct\n");
r1=((-b+sqrt(d))/(2*a));
r2=((-b-sqrt(d))/(2*a));
printf("r1=%f \nr2=%f",r1,r2);
}
if(d<0)
{
printf("roots are imaginary\n");
d=-d;
r1=((-b)/(2*a));
r2=((sqrt(d)/(2*a)));
printf("r1=%f+i %f \nr2=%f-i %f",r1,r2,r1,r2);
}
}
getch();
}
No comments:
Post a Comment