What is the minimum requirement for a recursive function to terminate successfully?
- It must have an iterative loop.
- It must have a base case.
- It should call other functions.
- It should be complex in nature.
For a recursive function to successfully terminate, it must have a base case. A base case is a condition under which the function stops calling itself and starts returning values. Without a base case, a recursive function would call itself indefinitely, leading to an infinite loop and, in most cases, a stack overflow error.
Loading...
Related Quiz
- How does the compiler treat the conditions in a nested if-else structure?
- Your team is developing a C++ application involving several classes with complex interrelationships and data handling. How can abstraction be effectively implemented to simplify the interactions between different class objects and the user?
- Which keyword is used to define a template in C++?
- What is the primary difference between abstraction and encapsulation in C++?
- In a for loop, if a continue statement is executed, then the control jumps to _______.