#include<stdio.h>
#include<math.h>
main ()
{
int a,b,c,r1,r2,x,y;
float d;
printf("enter the values of coefficients a,b,c\n");
scanf("%d%d%d",&a,&b,&c);
while (a == 0)
{
printf("reenter the value of a");
scanf("%d",&a);
printf("\n");
}
d = ( b * b ) - (4 * a * c);
if(d==0){
printf("roots are equal\n");
printf("r1=%f r2=%f ", -b/(2*a), -b/(2*a));
}
else if(d>0){
printf("roots are real and unequal");
printf("r1=%f r2=%f ,(-b + sqrt(d))/(2*a),(-b - sqrt(d))/(2*a) );
}
else{
x = -b/(2*a);
y = sqrt(d)/(2*a);
printf("roots are imaginary.\n");
printf("r1=%f r2=%f ",x+(i*y) , x - (i*y));
}
}
No comments:
Post a Comment