C Programming Multiple Choice Question - Recursion

This section focuses on the "Recursion" in C programming. These Multiple Choice Questions (MCQ) should be practiced to improve the C programming skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. The process in which a function calls itself directly or indirectly is called?

A. Recursion
B. Type Conversions
C. Constant
D. Abstract Classes

View Answer


2. A function fun is called __________ if it calls the same function fun.

A. indirect recursive
B. direct recursive
C. Both A and B
D. None of the above

View Answer


3. Which of the following is not an example of recursion?

A. Towers of Hanoi (TOH)
B. DFS
C. Inorder Tree Traversals
D. SFS

View Answer


4. When any function is called from main(), the memory is allocated to it on the stack.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not Say

View Answer


5. Iteration requires more system memory than recursion.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not Say

View Answer


6. When a recursive function is called in the absence of an exit condition, it results in an infinite loop due to which the stack keeps getting filled(stack overflow). This results in a run time error.

A. TRUE
B. FALSE
C. Can be true or false
D. Can not Say

View Answer


7. The data structure used to implement recursive function calls _____________

A. Array
B. Linked List
C. Binary tree
D. Stack

View Answer


8. What will be output for the following code?

#include <stdio.h>
main()
{
    int num=5;
    int fun(int num);
    printf(""%d"",fun(num));
}
int fun(int num)
{
    if(num>0)
        return(num+fun(num-2));
}

A. 6
B. 7
C. 8
D. 9

View Answer


9. What will be output for the following code?

int main()
{
    printf(""Hello"");
    main();
    return 0;
}

A. Hello is printed once
B. Hello infinite number of times
C. Hello is not printed at all
D. 0 is returned

View Answer


10. Which of the following is true about recursion?

A. Recursion provides a clean and simple way to write code.
B. The recursive program has less space requirements than iterative program
C. The principle of stack is FIFO
D. All of the above

View Answer






Discussion



* You must be logged in to add comment.

Anjali Shinde
main() { int num=5; int fun(int num); printf(""%d"",fun(num)); } int fun(int num) { if(num>0) return(num+fun(num-2)); } how answer is 8?