/*Solution of a quadratic equation*/
#include<math.h>
#include<stdio.h>
int main()
{
float a, b, c, d, x1, x2, rp, imp;
int i;
for(i=1;i<=3;i++)
{
printf("Enter the values of a:");
scanf("%f", &a);
printf("Enter the values of b:");
scanf("%f", &b);
printf("Enter the values of c:");
scanf("%f", &c);
d=b*b-4*a*c;
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
if(x1==x2)
{
printf("\n The roots are equal");
printf("\n The root is: %.3f\n\n", x1);
}
else
{
printf("\n The roots are not equal");
printf("\n The 1st root is: %.3f", x1);
printf("\n The 2nd root is: %.3f\n\n", x2);
}
}
return(0);
}
#include<math.h>
#include<stdio.h>
int main()
{
float a, b, c, d, x1, x2, rp, imp;
int i;
for(i=1;i<=3;i++)
{
printf("Enter the values of a:");
scanf("%f", &a);
printf("Enter the values of b:");
scanf("%f", &b);
printf("Enter the values of c:");
scanf("%f", &c);
d=b*b-4*a*c;
x1=(-b+sqrt(d))/(2*a);
x2=(-b-sqrt(d))/(2*a);
if(x1==x2)
{
printf("\n The roots are equal");
printf("\n The root is: %.3f\n\n", x1);
}
else
{
printf("\n The roots are not equal");
printf("\n The 1st root is: %.3f", x1);
printf("\n The 2nd root is: %.3f\n\n", x2);
}
}
return(0);
}
Comments
Post a Comment