w3resource

C++ Recursion: Exercises, Practices, Solutions

C++ recursion function[16 exercises with solution]

[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]

1. Write a C++ program to find the sum of all elements in an array using recursion.

Click me to see the solution

2. Write a C++ program to calculate the factorial of a given number using recursion.

Click me to see the solution

3. Write a C++ program to implement a recursive function to get the nth Fibonacci number.

Click me to see the solution

4. Write a C++ program to implement a recursive function to calculate the sum of digits of a given number.

Click me to see the solution

5. Write a C++ program to implement a recursive function to find the maximum and minimum elements in an array.

Click me to see the solution

6. Write a C++ program to reverse a string using recursion.

Click me to see the solution

7. Write a C++ program to implement a recursive function to calculate the power of a number.

Click me to see the solution

8. Write a C++ program to implement a recursive function to check if a given string is a palindrome.

Click me to see the solution

9. Write a C++ program to implement a recursive function to reverse a linked list.

Click me to see the solution

10. Write a C++ program to implement a recursive function to find the greatest common divisor (GCD) of two numbers.

Click me to see the solution

11. Write a C++ program to implement a recursive function to count the number of occurrences of a specific element in an array of integers.

Click me to see the solution

12. Write a C++ program to implement a recursive function to generate all permutations of a given string.

Click me to see the solution

13. Write a C++ program to implement a recursive function to calculate the product of two numbers without using the multiplication operator.

Click me to see the solution

14. Write a C++ program to implement a recursive function to calculate the sum of even and odd numbers in a given range.

Click me to see the solution

15. Write a C++ program to implement a recursive function to check if a given binary tree is a binary search tree.

Click me to see the solution

16. Write a C++ program to implement a recursive function to find the sum of all prime numbers in a given range.

Click me to see the solution

CPP Code Editor:

More to Come !

Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/cpp-exercises/recursion/index.php