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.
2. Factorial Using Recursion
Write a C++ program to calculate the factorial of a given number using recursion.
3. Recursive nth Fibonacci Number
Write a C++ program to implement a recursive function to get the nth Fibonacci number.
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.
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.
6. Reverse a String Using Recursion
Write a C++ program to reverse a string using recursion.
7. Power Calculation Using Recursion
Write a C++ program to implement a recursive function to calculate the power of a number.
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.
9. Reverse a Linked List Using Recursion
Write a C++ program to implement a recursive function to reverse a linked list.
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.
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.
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.
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.
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.
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.
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.
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.