I have another problem I've spent a long time trying to solve. I know it's probably really simple but I cannot get it to work.

Here's the problem:

Write the definition of a function powerTo , which receives two parameters. The first is a double and the second is an int . The function returns a double .

If the second parameter is negative, the function returns 0. Otherwise, it returns the value of the first parameter raised to the power of the second.

Here's my attempt:

Code:

double powerTo(double base, int power)
{
int n;
for (int k = 1; k < n; k++) {
if (power < 0)
return base *= power;
else
return 0;
}
}

This is the error message I get from codelab:

Code:

Sometimes your code doesn't return a value.

I really would appreciate someone's help on this, I think it's something pretty easy but I'm just lost on this one.