Practice 50 C# Recursion Programming Questions, TechnoVlogs

Practice 50 C# Recursion Programming Questions


Q1. Write a C# program to calculate the factorial of a number using recursion.  
  Input: Number = 5  
  Output: Factorial = 120

Q2. Write a C# program to find the nth Fibonacci number using recursion.  
  Input: n = 5  
  Output: Fibonacci = 5

Q3. Write a C# program to calculate the power of a number using recursion.  
  Input: Base = 2, Exponent = 3  
  Output: Power = 8

Q4. Write a C# program to check if a number is a palindrome using recursion.  
  Input: Number = 121  
  Output: Palindrome

Q5. Write a C# program to find the sum of natural numbers up to n using recursion.  
  Input: n = 5  
  Output: Sum = 15

Q6. Write a C# program to calculate the sum of digits of a number using recursion.  
  Input: Number = 1234  
  Output: Sum of digits = 10

Q7. Write a C# program to print a number in reverse order using recursion.  
  Input: Number = 1234  
  Output: 4321

Q8. Write a C# program to check if a string is a palindrome using recursion.  
  Input: String = "madam"  
  Output: Palindrome

Q9. Write a C# program to find the greatest common divisor (GCD) of two numbers using recursion.  
  Input: a = 12, b = 18  
  Output: GCD = 6

Q10. Write a C# program to calculate the sum of even numbers up to n using recursion.  
   Input: n = 6  
   Output: Sum = 12

Q11. Write a C# program to calculate the sum of odd numbers up to n using recursion.  
   Input: n = 6  
   Output: Sum = 9

Q12. Write a C# program to find the number of digits in a number using recursion.  
   Input: Number = 1234  
   Output: Number of digits = 4

Q13. Write a C# program to print the Fibonacci sequence up to n terms using recursion.  
   Input: n = 5  
   Output: 0 1 1 2 3

Q14. Write a C# program to calculate the sum of numbers from 1 to n using recursion.  
   Input: n = 5  
   Output: Sum = 15

Q15. Write a C# program to find the power of a number using recursion (without using the Math.Pow method).  
   Input: Base = 3, Exponent = 4  
   Output: Power = 81

Q16. Write a C# program to calculate the factorial of a number recursively for a large value.  
   Input: Number = 10  
   Output: Factorial = 3628800

Q17. Write a C# program to find the sum of squares of first n natural numbers using recursion.  
   Input: n = 3  
   Output: Sum of squares = 14

Q18. Write a C# program to find the sum of cubes of first n natural numbers using recursion.  
   Input: n = 3  
   Output: Sum of cubes = 36

Q19. Write a C# program to calculate the nth triangular number using recursion.  
   Input: n = 4  
   Output: Triangular number = 10

Q20. Write a C# program to find the product of digits of a number using recursion.  
   Input: Number = 1234  
   Output: Product of digits = 24

Q21. Write a C# program to find the length of a string using recursion.  
   Input: String = "hello"  
   Output: Length = 5

Q22. Write a C# program to reverse a string using recursion.  
   Input: String = "hello"  
   Output: String = "olleh"

Q23. Write a C# program to print the first n natural numbers in reverse order using recursion.  
   Input: n = 5  
   Output: 5 4 3 2 1

Q24. Write a C# program to print the factorial of a number recursively.  
   Input: Number = 5  
   Output: Factorial = 120

Q25. Write a C# program to calculate the nth power of a number using recursion.  
   Input: Base = 2, Exponent = 3  
   Output: Power = 8

Q26. Write a C# program to find the sum of all elements in an array using recursion.  
   Input: Array = [1, 2, 3, 4]  
   Output: Sum = 10

Q27. Write a C# program to find the maximum element in an array using recursion.  
   Input: Array = [1, 2, 3, 4]  
   Output: Maximum = 4

Q28. Write a C# program to calculate the nth Fibonacci number recursively.  
   Input: n = 6  
   Output: Fibonacci = 8

Q29. Write a C# program to calculate the sum of digits of a number recursively.  
   Input: Number = 1357  
   Output: Sum of digits = 16

Q30. Write a C# program to reverse an array using recursion.  
   Input: Array = [1, 2, 3, 4]  
   Output: Reversed array = [4, 3, 2, 1]

Q31. Write a C# program to find the first digit of a number using recursion.  
   Input: Number = 9876  
   Output: First digit = 9

Q32. Write a C# program to find the last digit of a number using recursion.  
   Input: Number = 9876  
   Output: Last digit = 6

Q33. Write a C# program to find the sum of even digits of a number using recursion.  
   Input: Number = 123456  
   Output: Sum of even digits = 12

Q34. Write a C# program to find the sum of odd digits of a number using recursion.  
   Input: Number = 123456  
   Output: Sum of odd digits = 9

Q35. Write a C# program to find the nth number in the Fibonacci series using recursion.  
   Input: n = 7  
   Output: Fibonacci = 13

Q36. Write a C# program to find the factorial of a number recursively with a base case.  
   Input: Number = 6  
   Output: Factorial = 720

Q37. Write a C# program to calculate the product of the first n natural numbers using recursion.  
   Input: n = 4  
   Output: Product = 24

Q38. Write a C# program to print the sum of all even numbers from 1 to n using recursion.  
   Input: n = 10  
   Output: Sum = 30

Q39. Write a C# program to check if a number is a perfect number using recursion.  
   Input: Number = 6  
   Output: Perfect number

Q40. Write a C# program to find the product of elements in an array using recursion.  
   Input: Array = [1, 2, 3, 4]  
   Output: Product = 24

Q41. Write a C# program to reverse a string recursively by swapping characters.  
   Input: String = "abcdef"  
   Output: String = "fedcba"

Q42. Write a C# program to find the sum of an array of integers using recursion.  
   Input: Array = [1, 2, 3, 4, 5]  
   Output: Sum = 15

Q43. Write a C# program to count the number of occurrences of a number in an array using recursion.  
   Input: Array = [1, 2, 3, 2], Number = 2  
   Output: Count = 2

Q44. Write a C# program to print all the divisors of a number using recursion.  
   Input: Number = 6  
   Output: Divisors = 1 2 3 6

Q45. Write a C# program to generate the first n prime numbers using recursion.  
   Input: n = 5  
   Output: Prime numbers = 2 3 5 7 11

Q46. Write a C# program to calculate the nth triangular number using recursion.  
   Input: n = 6  
   Output: Triangular number = 21

Q47. Write a C# program to find the number of vowels in a string using recursion.  
   Input: String = "hello"  
   Output: Number of vowels = 2

Q48. Write a C# program to check if a number is a power of two using recursion.  
   Input: Number = 8  
   Output: Power of two

Q49. Write a C# program to find the second largest element in an array using recursion.  
   Input: Array = [10, 20, 4, 45, 99]  
   Output: Second largest = 45

Q50. Write a C# program to check if a number is a prime number using recursion.  
   Input: Number = 17  
   Output: Prime

Social Share

Bikki Singh Instructor TechnoVlogs

Bikki Singh

Hi, I am the instructor of TechnoVlogs. I have a strong love for programming and enjoy teaching through practical examples. I made this site to help people improve their coding skills by solving real-world problems. With years of experience, my goal is to make learning programming easy and fun for everyone. Let's learn and grow together!