1,270 views
3 votes
3 votes
Will recursion work correctly in a language with static allocation of all variables? Explain.

1 Answer

16 votes
16 votes

Recursion cannot be used for static variables since the memory for static variables is allocated only once during compilation time. So, if we use recursion, then it may give incorrect result. Generally, we do not want such things when implementing recursion.

For detailed explanation, refer http://stackoverflow.com/questions/10290527/why-do-static-variables-not-allow-recursion

edited by

Related questions

5 votes
5 votes
1 answer
1
1 votes
1 votes
1 answer
4
makhdoom ghaya asked Nov 30, 2016
725 views
Consider the definition of macro $B,$ nested within the definition of a macro $A.$ Can a call to macro $B$ also appear within macro $A?$ If not, why not? If yes, explain ...