What happens when a recursive function in C lacks a proper base condition?
Explanation
In C programming, a recursive function must have a base condition to terminate the recursive calls. When this condition is missing, the function continues to call itself indefinitely.
Mathematically, if we represent the depth of the recursion stack as D, and the maximum stack size available to the process as Smax, the program will encounter a fatal error when:
D≥Smax
As the function calls itself without a base case, it consumes stack memory for every frame. Once the memory limit is exceeded, the system triggers a stack overflow, causing the program to crash.