Redefine the function power so that it also works for negative exponents.
In order to do this you will also have to change the type of the value
returned to double. The function declaration and header comment for the
redefined version of power is as follows:
double power(int x, int n);
//Precondition: If n < 0, then x is not 0.
//Returns x to the power n.
Sorry the answer is not available at the moment…
If you are able to find the answer, please make sure to post it here. So that your Juniors have smile on their lips and feel happy.
Spread the 'tradition of sharing'.