Question: 2. 6 Q3 Solving quadratic equation Write a C program, named quadratic.c, to solve the quadratic equation ax2 + bx + C = 0 of

 2. 6 Q3 Solving quadratic equation Write a C program, named
quadratic.c, to solve the quadratic equation ax2 + bx + C =
0 of given coefficients a, b and c When running the program,
it prompts for the input of coefficients a, b, c as the

2. 6 Q3 Solving quadratic equation Write a C program, named quadratic.c, to solve the quadratic equation ax2 + bx + C = 0 of given coefficients a, b and c When running the program, it prompts for the input of coefficients a, b, c as the float type numbers. After inputting three float numbers, it computes and prints out the solutions, then prompts for another round of inputting. Your program will quit when getting input 0,0,0. Your program should handle four situations 1. a-0, not a quadratic equation; 4ac = 0, the equation has two equal roots; 3.62 4ac 0, the equation has distinct real roots. Your program should be robust for invalid inputs. The output formats of different coefficients should be as shown in the following test Public test gcc quadratic.c -o quadratic quadratic Please enter the coefficients a,b,c 1,2,1 The equation has two equal real roots X:-1.000000 Please enter the coefficients a,b,c 1, 2,2 The equation has two complex roots real: -1.000eee imaginary:1.000000 Please enter the coefficients a,b,c 2,6,1 The equation has two distinct real roots X1-0.177124 X2: 2.822875 LOM Public test gec quadratic.c -o quadratic quadratic Please enter the coefficients a, b, 1,2,1 The equation has two equal real roots X:-1.000000 Please enter the coefficients a,b,c 1,2,2 The equation has two complex roots. real:-1.000000 imaginary:1.000000 Please enter the coefficients a,b,c 2,6,1 The equation has two distinct real roots x1:-0.177124 X2: -2.822875 Please enter the coefficients a, b,c 0,1,2 input:not a quadratic equation Please enter the coefficients a, b, c a, a, a input: Invalid input Please enter the coefficients a,b,c 12 input: Invalid input Please enter the coefficients a, b, 8,9,0 Input:quit Create program file quadratic c, refer to the following programming structure. // program signature #include #include // need this Library for maths functions fabs() and sqrt() #define EPSILON 0.000001 or #define EPSILON 12-6 int main() { // setbuf(stdout, NULL); // uncomment this line for using Eclipse console float a, b, c, d, x1, x2; int inn; char temp do { // do-while for new input problem do { // do-while loop to get correct input of three floating numbers printf("Please enter the coefficients a,b,c "); inn - scanf("%f %f, Xf", &a,&b,&c); if (inn 1-3) { printf("input: Invalid input "); } else break; do { flush the input buffer scanf("%d", &temp); if (temp in break; > while (1) } while (1); } else break; do { // flush the input buffer scanf("%c", &temp); if (temp ' ') break; } while (1); } while (1); PALON if (fabs(a)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!