Question: Write a function: void solveQuadratic ( double a , double b , double c , double& x 1 , double& x 2 ) Use the

Write a function:
void solveQuadratic(double a, double b, double c, double& x1, double& x2)
Use the quadratic formula to solve the quadratic equation given by ax2+ bx + c =0. You will have to do the math twice - once for the version that says -b +... and once for the version that says -b -...
Use x1 and x2 to communicate the answers. x1 should store the result to the + version of the formula and x2 should store the - version. If there is only one answer, both x's will be the same. Do not worry about cases with no solution.
Code:
1
#include
2
#include
3
using namespace std;
4
// Any changes above will be ignored
5
// YOUR_CODE_BELOW
6
7
// YOUR_CODE_ABOVE
8
// Any changes below will be ignored
9
int main(){
10
double answer1=0, answer2=0;
11
double in1, in2, in3;
12
cin >> in1>> in2>> in3;
13
solveQuadratic(in1, in2, in3, answer1, answer2);
14
15
// If answer1 and 2 are still 0, your function did not modify them
16
cout << answer1<<","<< answer2<< endl;
17
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!