Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double quadplus(float a, float b, float c);
- double quadminus(float a, float b, float c);
- int main()
- {
- double a, b, c;
- double discriminant;
- cout << "Please Enter variables for a, b, and c." << endl << endl;
- cout << "Enter number for variable a." << endl << endl;
- cin >> a;
- cout << "Enter number for variable b." << endl << endl;
- cin >> b;
- cout << "Enter number for variable c." << endl << endl;
- cin >> c;
- discriminant = (b * b) - (4 * a * c);
- if(discriminant == 0)
- cout << quadplus(a,b,c) << endl;
- else if(discriminant > 0)
- cout << quadplus(a,b,c) << endl;
- else if(discriminant < 0)
- cout << quadminus(a,b,c) << quadplus(a,b,c) << endl;
- return 0;
- }
- double quadplus(float a, float b, float c)
- {
- return ((-1 * b) + (sqrt(( b * b) - (4 * a * c))) / (2 * a));
- }
- double quadminus(float a, float b, float c)
- {
- return ((-1 * b) - (sqrt(( b * b) - (4 * a * c))) / ( 2 * a));
- }
- cout << quadplus << endl;
- cout << quadplus(a, b, c) << endl;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement