After the user inputs an A, B and c value it gives me an x and y value. This is the quadratic formular −𝑏±√𝑏2 −4𝑎𝑐 2𝑎. The questions requires me to use a void function and use the return value.
Below is my code and I am having some error on this. Please help me.
void getx(double A, double B, double C);
void gety(double A, double B, double C);
int main(){
double a;
double b;
double c;
cout << " this program calculates the value of x and y value " << endl;
cout << " Please enter value a,b and c " << endl;
cin>>a;
cin>>b;
cin>>c;
getx(a,b,c);
gety(a,b,c);
cout << " value of x " << x << endl;
cout << " value of -x" << y << endl;
return 0;
}
void getx(double A, double B, double C)
{
double x;
x = (B + (1/2(B * B - 4 * A * C))) / (2 *A);
return x;
}
void gety(double A, double B, double C)
{
double y;
Follow your instructions, but I presume “x” and “y” are for the left and right roots, right? (It is odd to refer to a coordinate value on the X axis as “y”.)
By putting this all in one function you’ll need to be more careful about how you compute your roots.
1. Find your discriminant (the stuff under the radical). If negative, there are no real roots. Set x1 and x2 both equal to NaN or something and return;