Invalid operands of types

I am given an error "invalid operands of types 'double' and 'int' to binary 'operator^'" for my formula in the code "principal = (principal*(interestRate/12)*1+(interestRate/12) *(pow(numYears*12, interestRate)))/(((1+(interestRate/12))^(numYears*12)+1));". How do I fix this?

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
   int main()
{
    double principal, interestRate, monthlyPayment;
    int numYears;
    cout.setf(ios_base::fixed , ios_base::floatfield);
    cout.precision(2);

    cout << "This is a monthly payments program.\n\n";

    cout << "Enter the loan amount: $"; // enter 10,000 here
    cin >> principal;
    cout << "Enter the rate percent: "; // you enter .12 here
    cin >> interestRate;
    cout << "Enter the desired monthly payment: $";
    cin >> monthlyPayment;

    while (interestRate >=1)
    {
        interestRate = interestRate/ 100;
    }
    numYears = 30;
    interestRate = 0.07;
    principal = (principal*(interestRate/12)*1+(interestRate/12) *(pow(numYears*12, interestRate)))/(((1+(interestRate/12))^(numYears*12)+1));

    cout << "\n\n";
    cout << "Loan Amount:                  $" << principal << endl;
    cout << "Interest Rate:                 " << intRate << "%" << endl;
    cout << "Monthly Payment:              $" << monthly << endl;


    return 0;
}
closed account (48T7M4Gy)
raising a number to a power does not use '^'

See the tutorial on "pow" function
Oh I see the problem, I forgot to add pow to that function too. Thanks.
Topic archived. No new replies allowed.