Question

(C PROGRAM PLEASE) Write a recursive function power( base, exponent ) that when invoked returns baseexponent...

(C PROGRAM PLEASE)

Write a recursive function power( base, exponent ) that when invoked returns baseexponent For example, power( 3, 4 ) = 3 * 3 * 3 * 3. Assume that exponent is an integer greater than or equal to 1. Hint: The recursion step would use the relationship baseexponent = base * base exponent–1 and the terminating condition occurs when exponent is equal to 1 because base1 = base.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

int power(int base, int exponent)
{
  
if( exponent == 1 )
return base;
else
return base * power(base, exponent­1);
}

Add a comment
Know the answer?
Add Answer to:
(C PROGRAM PLEASE) Write a recursive function power( base, exponent ) that when invoked returns baseexponent...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT