+ 1

What is the output of c program if we will not give the terminating condition in recursion.

15th Feb 2022, 10:38 AM
Rohan Laal
Rohan Laal - avatar
2 Réponses
+ 4
This is an run time error. If there is no stoping condition it calls it again and again nd calling of a functions add address to the stack where it leave the function. Stack has finite size of memory so a point came when its full and cause stack overflow at run time and terminate abruptly, You Can Try #include <stdio.h> int i=0; int func(){ i+=1; func(); } int main() { func(); return 0; } this code
15th Feb 2022, 11:00 AM
Mask Man(What's in a name?)
Mask Man(What's in a name?) - avatar
+ 4
If a recursion never reaches a base case(terminating condition), it will go on making recursive calls forever and the program will never terminate. This is known as infinite recursion, and it is generally not considered a good idea. In most programming environments, a program with an infinite recursion will not really run forever. You will just get a stack overflow.
15th Feb 2022, 10:57 AM
Kashyap Kumar
Kashyap Kumar - avatar