Question #4936

whenever i compiled the following program this erroe apears ambiguous call to overload function
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int power;
int i=0;
int j=1;
while ((i<=10)&&(j<=11))
{
j=j+1;
i=i+1;
power=pow(int (i), int( j));
cout<<power<<",";
}
return 0;
}

Expert's answer

The problem is that there is not such prototype of pow function which takes two integers as parameters.

Instead of writing

power=pow(int (i), int( j));

you can try any from the following:

power=pow(double (i), j);

power=pow(long double (i), j);

power=pow(float (i), j);

Instead of writing

power=pow(int (i), int( j));

you can try any from the following:

power=pow(double (i), j);

power=pow(long double (i), j);

power=pow(float (i), j);

## Comments

## Leave a comment