void pow(double base, int exponent, double result);
int main()
{
double result;
pow(10, 6, result);
cout<<fixed;
cout<<"10 to the power of 6 yields "<<setprecision(0)<<result<<endl;
return 0;
}
// Q3. Modify function pow() such that the program outputs 1000000 rather than 0.
void pow(double base, int exponent, double result)
{
result=1;
while (exponent>0)
{
double result;
result = base * result;
exponent = exponent-1;
}
}
I having problems with my code can anyone help me figure this out. What I am suppose to do with the code is 1.modify the pow function so it displays 100000 instead 0 and 2.Change power() to a value-returning function that returns the result of base to the power of exponent. Rewrite the whole program so that it works correctly with the new power().
1) Change the name of your function from pow to power
2) The function currently returns void. Change that to return a double
3) Return the result from the function rather than assign it to the 'result' parameter.