Programming for Problem Solving (3110003) MCQs

MCQs of Recursion

Showing 1 to 10 out of 20 Questions
1.
When function calls itself, it is known as ______.
(a) recursion
(b) exit control loop
(c) nested loop
(d) user-defined function
Answer:

Option (a)

2.
Recursion is a process in which a function calls
(a) itself
(b) another function
(c) main() function
(d) None of these
Answer:

Option (a)

3.
A recursive function can be replaced with __ in C
(a) for loop
(b) while loop
(c) do while loop
(d) All of these
Answer:

Option (d)

4.
A recursive function is faster than __ loop
(a) for loop
(b) while loop
(c) do while loop
(d) None of these
Answer:

Option (d)

5.
A recursive function without if and else conditions will always lead to?
(a) Finite loop
(b) Infinite loop
(c) Incorrect result
(d) Correct result
Answer:

Option (b)

6.
What is the C keyword that must be used to get the expected result using Recursion?
(a) printf
(b) void
(c) break
(d) return
Answer:

Option (d)

7.
Recursion is similar to which of the following?
(a) switch case
(b) loop
(c) if-else
(d) if elseif else
Answer:

Option (b)

8.
How many functions are required to create a recursive functionality?
(a) One
(b) Two
(c) More than two
(d) None of these
Answer:

Option (a)

9.
What is the output?

int sum(int);
int main()
{
    int b;
    b = sum(4);
    printf("%d", b);  
}
int sum(int x)
{
    int k=1;
    if(x<=1)
     return 1;
    k = x + sum(x-1);
    return k;
}

(a) 10
(b) 11
(c) 12
(d) 15
Answer:

Option (a)

10.
What is the output?

int mul(int);
int main()
{
    int b;
    b = mul(3);
    printf("%d", b);
}
int mul(int x)
{
    if(x<=1)
     return 1;
    return (x * mul(x-1));
}

(a) 2
(b) 3
(c) 6
(d) 1
Answer:

Option (c)

Showing 1 to 10 out of 20 Questions