Respuesta :
Answer:
// here is program in C.
// include header
#include <stdio.h>
#include<math.h>
// main function
int main()
{
// variables
int a,b,c;
float d;
printf("enter the value of a,b,c :");
// read the value of a,b,c
scanf("%d %d %d",&a,&b,&c);
// find the discriminant
d=b*b-(4*a*c);
// if d=0 then no real root
if(d<0)
printf("The equation has no real roots \n");
//// d=0 then equation has one root
else if(d==0)
{
// find the root
float root=-b/(2*a);
printf("only root of the equation is:%f \n",root);
}
// d>=0 then equation has two real roots
else if(d>0)
{
// calculate both roots
float root1=(-b+sqrt(d))/(2*a);
float root2=(-b-sqrt(d))/(2*a);
// print both the roots
printf("first root of the equation is:%f \n",root1);
printf("second root of the equation is:%f \n",root2);
}
return 0;
}
Explanation:
Read the value of a,b,c from user.Calculate discriminant "d" as b^2 - 4ac . If the value of discriminant(d) is less than 0 then there will be no real root. If discriminant(d) is equal to 0 then quadratic equation has only one root which is -b/2a. Calculate the only root and print it.If discriminant(d) is greater than 0 then quadratic equation has two root as root1= (-b + sqrt(b^2 - 4ac)) / (2a) and root2 = (-b - sqrt(b^2 - 4ac)) / (2a). calculate both the roots and print them.
Output:
enter the value of a,b,c :1 6 4
first root of the equation is:-0.763932
second root of the equation is:-5.236068
Answer:
should be C
Explanation:
EDG2021 comment for my mixtape