Hello I need help my iPow function does not seem to calculate the inputs.
The program is just a simple program to calculate x^n . However I need to use a function.The output it generates now is exactly the same as the integer.
#include <iostream>
usingnamespace std;
float x, answer;
int i, n;
float iPow()
{
answer =1;
for( i=1; i <=n ; i++)
{
answer *= x;
return answer ;
}
}
int main()
{
cout << " Enter a number and a non-negative integer " << endl;
cin >> x >> n;
cout << x << " to the power " << n << " is " << endl;
cout << iPow() << endl;
return 0;
}