Variable cannot be used as a function

Getting an error in line
 
co2= pow(1-(1+int_month, time_period(-1));


I tried declaring the function right below the namespace, but i think the problem relates to the use of the variable rather than a declaration

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
#include <iostream>
#include <cmath>
using namespace std;

double pwr(double co2);
int main( )
{
    double loan_hand, int_rate, face_value, monthly_payment,
    time_period, int_month, co1, co2, mp1, loan_amount;
    
    cout<< "Please enter amount in hand?\n";
    cin >> loan_hand;
    cout<< "Please enter the interest rate?\n";
    cin >> int_rate;
    cout << "Please enter the time period in months.\n";
    cin >> time_period; 
    
int_month=int_rate/12; 

monthly_payment=loan_hand/time_period;



co1=monthly_payment/int_month;
co2= pow(1-(1+int_month, time_period(-1));

loan_amount=co1*co2; 
cout << "you will need a loan with a face value" << loan_amount;     
    system("PAUSE");
    return EXIT_SUCCESS;
}



Using a dev C++ compiler, the variable time_period appears to be considered a function and I'm not sure why. I know this is simple and appreciate any clear or concise answer, or a track to find as such.

Thank You
time_period is declared as a double. Therefore time_period(-1) is incorrect.

Try either

co2= pow(1-1+int_month, time_period-1);
or
co2= pow(1-1+int_month, time_period);
or
co2= pow(1-1+int_month, -1);

depending on what you are trying to do.
Last edited on
You are putting parentheses after it like its a function, so the compiler is complaining that it isn't.

If you want multiplication, use the * symbol.
Also you have mismatched parenthesis.
You're only passing one argument to pow(), it needs two:
double x = pow(2.0, 3); // x = 8
Last edited on
Topic archived. No new replies allowed.