Write a complete c program to report on the roots of a


Write a complete C++ program to report on the roots of a quadratic equation ax2 + bx + c = 0, a ≠ 0. The formula for the roots is

-b ± √b2 - 4ac/2a

If the discriminant, b2 - 4ac, is zero, there is a single root. If b2 - 4ac > 0, there are two real roots. If b2 - 4ac < 0, there are two complex roots. For b2 - 4ac >= 0, the program can compute the roots.

Input: The values of a, b, and c are stored in an input file on the h: drive named quadratic.txt.

Processing: A value-returning function will be used to compute b2 - 4ac.

Output: The type and number of the roots (single real root, two real roots, two complex roots) and, if b2 - 4ac >= 0, the root value(s).The output is written to a file on the h: drive named results.txt.

Tip: Use the function pow(x,y), which computes x raised to the power y (xy). If y = 0.5, pow(x,y) gives the square root of x. You need to include the cmath header file to use pow(x,y).

Note: Use the assert function (assert statement) to halt the program if division by zero is about to occur.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Write a complete c program to report on the roots of a
Reference No:- TGS0958598

Expected delivery within 24 Hours