Write a program to solve quadratic equation. A quadratic equation is one of the
ID: 3652687 • Letter: W
Question
Write a program to solve quadratic equation. A quadratic equation is one of the formsax^2 + bx + c = 0
Where a, b and c are double values that will differ from one equation to another. The
input to the program will be the three coefficients a, b, and c. The program outputs all
the roots of the equation. A root is a double value that makes the left-hand side of the
equation equal to zero when it is plugged in for x. There are two solutions to a quadratic
equation. The roots are computed by the following two almost identical formulas (where
a is not zero):
x = (-b + sqrt (b^2 - 4ac)) / 2a
and
x = (-b - sqrt (b^2 - 4ac)) / 2a
In order for the equation to have a double value as a root, the quantity b^2
Explanation / Answer
#include#include#include#include ofstream fout; ifstream fin; double calDiscriminant(double a,double b,double c); void main() { double a,b,c; double discriminant,root1,root2; fin.open("sample1.txt",ios::in); fout.open("sample2.txt",ios::out||ios::app); while(fin) { fin>>a; fin>>b; fin>>c; discriminant=calDiscriminant(a,b,c); foutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.