Write a flowchart and C program to solve quadratic equations aX2+bX+C=0
flowchart:
C code:
#include #include int main() { double a, b, c, deter, root1,root2, rlans, imgans; printf("Enter the values for a, b and c \\n"); scanf("%lf %lf %lf",&a, &b, &c); deter = b*b-4*a*c; if (deter > 0) { root1 = (-b+sqrt(deter))/(2*a); root2 = (-b-sqrt(deter))/(2*a); printf("root1 = %.2lf and root2 = %.2lf",root1 , root2); } else if (deter == 0) { root1 = root2 = -b/(2*a); printf("root1 = root2 = %.2lf;", root1); } else { rlans = -b/(2*a); imgans = sqrt(-deter)/(2*a); printf("root1 = %.2lf+%.2lfi and root2 = %.2f-%.2fi", rlans, imgans, rlans, imgans); } return 0; }
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
flowchart:
C code:
need an explanation for this answer? contact us directly to get an explanation for this answer