w3resource

C++ Recursion: Exercises, Practices, Solutions


This resource offers a total of 80 C++ recursion function problems for practice. It includes 16 main exercises, each accompanied by solutions, detailed explanations, and four related problems.

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


1. Sum of Array Using Recursion

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

Click me to see the solution


2. Factorial Using Recursion

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

Click me to see the solution


3. Recursive nth Fibonacci Number

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

Click me to see the solution


4. Sum of Digits Using Recursion

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. Recursive Maximum and Minimum in an Array

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. Reverse a String Using Recursion

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

Click me to see the solution


7. Power Calculation Using Recursion

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

Click me to see the solution


8. Check if a String is a Palindrome Using Recursion

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. Reverse a Linked List Using Recursion

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

Click me to see the solution


10. Greatest Common Divisor (GCD) Using Recursion

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. Count Occurrences of an Element in an Array Recursively

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. Generate All Permutations of a String Recursively

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

Click me to see the solution


13. Recursive Multiplication Without Using the Multiplication Operator

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. Recursive Sum of Even and Odd Numbers in a Range

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. Check if a Binary Tree is a Binary Search Tree Recursively

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. Sum of All Prime Numbers in a Range Using Recursion

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.



Follow us on Facebook and Twitter for latest update.