hello

ive been working on this project for the past couple of days, and i keep on getting the same error. it tells me that the term will not evaluate a function with two arguments. please help me! thanks

#include <iostream>
#include <cmath>
using namespace std;
int main ()

{

	double num1, num2, num3, pow, total;

	cout << "Loan Amount: ";
	cin >> num1;
	cout << "Monthly Interest Rate: ";
	cin >> num2;
	cout << "Number of Payments: ";
	cin >> num3;
	cout << "Monthly Payments: ";
	cin >> num2 * pow(1.0 + num2, num3) / (pow(1.0 + num2, num3) - 1) * num1;
	
	return 0;

}

Dani AI

Generated

Two quick fixes will get this program compiling and producing the correct monthly payment.

First, remove or rename the variable named pow. As noted, declaring a variable with the same name as the library function hides the function. When the compiler sees pow(...) it finds your double pow variable and then complains because a plain double is not callable. That is the root cause of the error you described. Rename that variable (for example powerFactor or just drop it if unused) or call the function explicitly as std::pow.

Second, the line that tries to show the result uses the extraction operator by mistake. You want to output the computed payment, not read into an expression. Replace the cin usage there with an output insertion (and compute the expression into a temporary variable first for clarity).

Other practical notes to avoid future issues: use an integer type for number of payments (or explicitly convert it) so the exponent is an integer when appropriate; ensure the interest rate is in decimal form (0.05 for 5%), or divide the entered percent by 100 inside the program; and consider formatting the final amount with std::fixed and std::setprecision(2) from <iomanip> for currency display. Contrary to 's partial list, modern C++ provides std::pow overloads including a double,double form, so the compilation error in this thread is name-hiding rather than an overload mismatch.

Enabling compiler warnings (for example -Wall -Wextra) will make typos like using cin instead of cout obvious.

Recommended Answers

All 2 Replies

Don't you mean cout? :)

However, after closer investigation, the error with pow() actually has to do with the fact that pow is only available in the following forms:

float std::pow(float, float)
long double std::pow(long double, long double)
double std::pow(double, int)
float std::pow(float, int)
long double std::pow(long double, int)

Take your pick.

You have a variable "pow" which is masking the function pow( ).

You don't use that variable, so remove it.

Also, in your red line, why are you doing cin >> num2 * ...... ? Don't you really want to be doing output?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.