0

# If/Else Statements

I'm trying to use if/else statements with the discriminant formula, b^2-4ac to print out the number of solutions and to print out the actual answers. rootCount in my main is saying that rootCount needs a pointer-to. #include<iostream> #include<string> using namespace std; double rootCount(double a, double b, double c); double d1(double a, double b, double c); double d2(double a, double b, double c); int main(void) { double a, b, c, d; double rootCount; cout << "Program uses the discriminant, b^2-4ac, to determine the number and type of roots." << endl; cout << "Enter a: "; cin >> a; cout << "Enter b: "; cin >> b; cout << "Eneter c: "; cin >> c; d = b * b - 4 * a * c; cout << "The number of solutions is: " << rootCount(a, b, c ) << endl; cout << "The solutions are: " << d1(a, b, c) << "and " << d2(a, b, c) << endl; system("pause"); return 0; } double rootCount (double a, double b, double c) { double d; d = b * b - 4 * a * c; if (d > 0) { cout << "Two solutions" << endl; } if (d == 0) { cout << "One solution" << endl; } else { cout << "No real solutions" << endl; } return d; } double d1(double a, double b, double c) { double d; d=(b*b - 4 * a*c); return d; } double d2 (double a, double b, double c) { double d; d= -1 * (b*b - 4*a*c); return d; }

9/6/2018 9:40:04 PM

Krista Clark