38.7k views
5 votes
How do you write a program that will solve the quadratic equationax2+bx=c=0

User Jbobbins
by
4.9k points

1 Answer

3 votes

Answer:

Hi, the general factorization formula, which will allow us to find the values for X of any polynomial of type Ах²⁺Вх+С.


\frac{ -b+\sqrt{b^(2) -4ac } }{2a}   and \frac{ -b-\sqrt{b^(2) -4ac } }{2a}

Step-by-step explanation:

This is one example taken from the C language:

int main()

{

int a,b,c,d;

float x,y;

printf("Input a: ");

scanf("%d",&a);

while (a == 0) {

printf("Input a: ");

scanf("%d",&a);

}

printf("Input b: ");

scanf("%d",&b);

printf("Input c: ");

scanf("%d",&c);

d = b*b-4*a*c;

if (d > 0) {

x = (-b+sqrt(d))/(2*a);

y = (-b-sqrt(d))/(2*a);

printf("x1 = %.2f\\",x);

printf("x2 = %.2f\\",y);

}

else if (d == 0) {

x = (-b)/(2*a);

printf("x1 = %.2f\\",x);

}

else

printf("The equation don't have solution.");

return 0;

}

User Croigsalvador
by
5.6k points