Problem: Write a program that willimplement a function for the quadratic formula
ID: 3614634 • Letter: P
Question
Problem: Write a program that willimplement a function for the quadratic formula to determine bothpossible values of x given input coefficients a, b, and c.
Yourprogram should read the coefficients a, b, and c from the inputtext file provided. Each row of the text file has one set ofcoefficients (a, b, and c in that order) for a single equation.
Each set of coefficients should be passed to your function thatwill carry out the quadratic formula. Your function should computethe two possible values of x for each set of coefficients.
Your program should also implement a second (value-returning)function called “num_positive” that takes the twopossible x values (previously computed by your quadratic formulafunction) as parameters and returns how many of the x values arepositive numbers. For example, if passed the x values 3 and 5, yourfunction should return 2. (Assume that 0 is a positive number forthis function.)
Your main() function should implement a loop that prints outthree things:
Sample output of one loop iteration:
a = 3, b = -2, c = -1
The value of x1 is: 1
The value of x2 is: -0.333333
1 of the x values is/are positive.
Explanation / Answer
please rate - thanks #include #include #include using namespace std; voidcompute(double&,double&,double,double&,double&,int&); int count(double,double); int main() {char filename[30]; double a,b,c,x1,x2; int pos; ifstream input; coutfilename; input.open(filename); //open file if(input.fail()) //is it ok? { couta) {input>>b>>c; coutRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.