Question: Language is c++ and need to run it in code blocks. this whole is one program so please write according to it. more practice with

Language is c++ and need to run it in code blocks.

this whole is one program so please write according to it.

more practice with recursion

write recursive functions to do each of the following. Create a main() function to call each of these functions to make sure that they work correctly. Note, you will receive no credit for functions that do not solve the problem recursively.

1. Write a function called power that takes two positive integers and raises the first to the power of the second. For example, power(2,4) would return 16 and power(3,3) would return 27. Here is the function prototype: int power(int base, int exponent);

2. Write a function called gcd that takes two integers and returns the greatest common divisor of the two integers. HINT: It might help to google Euclid gcd algorithm. Here is the function prototype:

int gcd(int M, int N);

3. Write a function called sumBetween that takes two integers and finds the sum of all integers between them inclusive. For example, sumBetween(6,8) would return 21, sumBetween(-2,-4) would return -9, and sumBetween(5,5) would return 5. Here is the function prototype:

int sumBetween(int X, int Y);

4. Write a function called sumEvens that takes two integers and finds the sum of all even integers between them inclusive. For example, sumEvens(6,10) would return 24, sumEvens(-3,-5) would return -4, sumEvens(5,5) would return 0, and sumEvens(8,8) would return 8. Here is the function prototype:

int sumEvens(int X, int Y);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!