Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program to ask the user to enter the coefficients a, b, and c of the qua

ID: 3640234 • Letter: W

Question

Write a program to ask the user to enter the coefficients a, b, and c of the quadratic
equation then computes and displays its solutions. The coefficients could be any real
numbers as long as a ? 0. The solutions are to be neatly displayed and their nature clearly identified (please see sample program run below). After printing the solution of the current equation, the program should ask the user if he/she wants to solve another equation. It will continue to do this as long as the user has more equations to be solved.
Sample Run:
The following shows sample runs of your program.

Please enter coefficient a: 1
Please enter coefficient b: 2
Please enter coefficient c: -3
The solutions to this quadratic equation are distinct and real:
x1 = -3 and x2 = 1
Another equation to solve? Type Y for YES, N for NO: n

I have the first part completed. I'm having trouble writing the code that asks the user whether or not to continue. It needs to re-run every time the user enters "y" and exit the program when the user enters "n". I was thinking a do/while loop, but I'm not sure how I would exit the program from there.

Explanation / Answer

#include main() { int a,b,c,d,p,q,r; printf(“Enter the co-efficients”); scanf(“%d%d%d”,&a&b&c); d=((b*b)-(4*a*c)); if(d==0) { printf(“Roots are real and equal”); f=-b/(2*a); printf(“x1=%d x2=%d”,f,f”); } else if(d>0) { printf(“Roots are real and distinct”); p=sqrt(d); q=(-b+e)/(2*a); r=(-b-e)/(2*a); printf(“x1=%d x2=%d”,q,r); } else { printf(“Roots are imaginary”); d=-d; p=sqrt(d); q=-b/(2*a); r=e/(2*a); printf(“x1=%d+%d x2%d-%d”,q,r,q,r); } getch(); }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote