Computer Science, asked by neneo5166, 4 months ago

Write an algorithm and draw a flowchart to find the root of a quadratic equation

Answers

Answered by uniquegalmercy
7

Answer:

Wait using the scanf() function for the user to enter the input. Calculate the roots of quadratic equation using the proper formulae.

...

Pseudo Code Algorithm:

Start.

Input a, b, c.

D ← sqrt (b × b – 4 × a × c).

X1 ← (-b + d) / (2 × a).

X2 ← (-b - d) / (2 × a).

Print x1, x2.

Stop.

Attachments:
Answered by maharamesh3107
2

Answer:

uadratic Equation

#include <math.h>

#include <stdio.h>

int main() {

double a, b, c, discriminant, root1, root2, realPart, imagPart;

printf("Enter coefficients a, b and c: ");

scanf("%lf %lf %lf", &a, &b, &c);

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

// condition for real and different roots

if (discriminant > 0) {

root1 = (-b + sqrt(discriminant)) / (2 * a);

root2 = (-b - sqrt(discriminant)) / (2 * a);

printf("root1 = %.2lf and root2 = %.2lf", root1, root2);

}

// condition for real and equal roots

else if (discriminant == 0) {

root1 = root2 = -b / (2 * a);

printf("root1 = root2 = %.2lf;", root1);

}

// if roots are not real

else {

realPart = -b / (2 * a);

imagPart = sqrt(-discriminant) / (2 * a);

printf("root1 = %.2lf+%.2lfi and root2 = %.2f-%.2fi", realPart, imagPart, realPart, imagPart);

}

return 0;

}

Similar questions