CBSE Class 12 Computer Science Question 69 of 101

Functions — Question 37

Back to all questions
37
Question

Question 33

Is it necessary to have a base case in a recursive function? Why/Why not?

Answer

Yes, it is necessary to have a base case in a recursive function. Without a base case, the recursive function would continue calling itself indefinitely, leading to infinite recursion. This can cause the program to run out of memory and crash, resulting in an error. The base case provides a condition that stops the recursion, allowing the function to return a result and terminate.