Write a c program that determines whether a quadratic equation has one real root
ID: 3560908 • Letter: W
Question
Write a c program that determines whether a quadratic equation has one real root, two real roots, or imaginary roots. Then, if the roots are real, display the roots of the quadratic equation. A quadratic equation is of the form . The discriminant of the equation is . If , then there are two real roots. If , then there is one real root, and if , then there are two imaginary roots. The roots of the equation are found using the quadratic equation:
1. Include the usual (detailed) comment block including program name, author, date, inputs, outputs and description, followed by your preprocessor directives.
2. After declaring your variables, explain the program to the user by printing a description to the monitor.
3. Call a function that prompts the user for each of the values of the coefficients a, b, and c for the quadratic equation and returns the value entered, with error checking for a valid input (scanf returned a value).
4. Call a function to calculate the discriminant D.
5. Use conditional statements to display the type of roots (one real, two real, or imaginary)
6. If the equation has real roots, use the quadratic equation to calculate the roots of the equation and display them. 7. At the end of your program, offer the user the option to run again or exit.
The program should in c please
test question
Test Equations
a) 2x2+8x+8=0 (One real root -> -2.0)
b) ?5x2+3x?4=0? (Two imaginary roots)
c) ?2x2+7x+4=0 (Two real roots -> -0.5, 4.0)
Explanation / Answer
#include #include #include using namespace std; void print(int ind, complex x) { coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.