#include<stdio.h>
#include<conio.h>
#include<math.h>
void main() {
float a,b,c,d,x1,x2;
clrscr();
printf("Enter coefficients a,b,c of Quadratic equation\n");
scanf("%f%f%f",&a,&b,&c);
d=(b*b)-(4*a*c);
if (d<0) printf("Roots are imagnary\n");
else {
if (d==0) {
printf("Roots are real and equal\n");
x1=x2=(-b)/(2*a);
printf("x1=%f and x2=%f\n",x1,x2);
}
else {
printf("Roots are real and diffreant\n");
x1=(-b)+(sqrt(d)/(2*a));
x2=(-b)-(sqrt(d)/(2*a));
printf("x1=%f and x2=%f\n",x1,x2);
}
}
getch();
}
No comments:
Post a Comment