C Recursion MCQ Questions and Answers

1. What is recursion in C programming?

a) A loop that iterates a fixed number of times
b) A function that calls another function
c) A function that calls itself
d) A method to declare variables

2. What is a base case in recursion?

a) The initial value for a recursive function
b) The condition under which the recursion stops
c) The maximum number of times a function can call itself
d) The main function in a recursive program

3. Which of the following is essential for a recursive function to avoid infinite recursion?

a) A loop
b) A global variable
c) A base case
d) A static variable

4. What is stack overflow in the context of recursive functions in C?

a) An error that occurs when the program runs out of memory
b) A situation where too many functions are called at once
c) An error that occurs when recursive calls exhaust the call stack
d) A condition where the stack data structure overflows

5. Which of the following problems is typically solved using recursion?

a) Calculating the factorial of a number
b) Swapping two variables
c) Finding the maximum value in an array
d) Printing a string

6. What is tail recursion in C programming?

a) A recursive function with no base case
b) A recursive function where the recursive call is the last operation
c) A recursive function that calls multiple functions
d) A recursive function without return statement

7. Can a recursive function in C have more than one base case?

a) No, a recursive function can only have one base case
b) Yes, but only in special circumstances
c) Yes, a recursive function can have multiple base cases
d) Yes, but all base cases must be identical

8. What is indirect recursion in C?

a) A function that calls itself multiple times
b) A function that calls a sequence of other functions, one of which calls the first function
c) A function that does not have a direct call to itself
d) A recursive function without a base case

9. In a recursive function, which memory area is primarily used for storing function calls?

a) Heap
b) Stack
c) Global memory
d) Static memory

10. How does recursion differ from iteration?

a) Recursion is faster than iteration
b) Recursion uses less memory than iteration
c) Recursion involves function calls, while iteration uses loops
d) Recursion can only solve simple problems

Comments