What's wrong with this equation?

In quadratic equation ax^2 + bx + c, there are two possible values for x. These lines of code set the values of x to both of the possible values. However, these lines do not work, and it always yields the error message: expected ')' before ';' token

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
    double a, b, c, x1, x2;
    char cont('y');
    cout << "Enter the values of a, b, and c in the equation ax^2 + bx + c = 0.\n";
    cout << "I will tell you all possible values of x.\n";
    
    do
    {
    cout << "a = ";
    cin >> a;
    
    //Tells the user that 'a' cannot be 0 and asks for it again
    while (a == 0)
    {cout << endl << "If a = 0, then it is not a quadratic formula.\nPlease enter another value.\n";
    cout << "\na = ";
    cin >> a;}
    
    
    cout << a;
    cout << "b = ";
    cin >> b;
    cout << b;
    cout << "c = ";
    cin >> c;
    cout << c;
    
    if (b * b - 4 * a * c < 0) //In case the problem has no solutions
    {cout << "This equation has no solutions.\n";
    break;}
    
    cout << endl << "The equation will be " << a << "x^2 + " << b << "x + " << c << " = 0.\n";

    x1 = (-b + sqrt(pow(b, 2.0) - 4 * a * c) / (2 * a);//Plus squareroot for x1
    x2 = (-b - sqrt(pow(b, 2.0) - 4 * a * c) / (2 * a);//Minus squareroot for x2
    
    cout << endl << "The two possible values of x are " << x1 << " and " << x2 << ".\n"; 
    
    cout << "Do you want to continue (y or n)? ";
    cin >> cont;
    
    }while (cont == 'y' || cont == 'Y');
    cout << endl << endl << endl;
    system("pause");
    return 0;
}


I should note that I am just beginning to use the #include <cmath> library.
1
2
(-b + sqrt(pow(b, 2.0) - 4 * a * c)
(-b - sqrt(pow(b, 2.0) - 4 * a * c)


Should be :
1
2
(-b + sqrt(pow(b, 2.0) - 4 * a * c)) // missing ')'
(-b - sqrt(pow(b, 2.0) - 4 * a * c)) // missing ')' 

Wow, thank you. I didn't actually think it was something that easy :(
Topic archived. No new replies allowed.