top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Is there a limit on recursion of main function in C/C++, how many times main function can call itself?

+1 vote
500 views
Is there a limit on recursion of main function in C/C++, how many times main function can call itself?
posted Mar 8, 2016 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Whenever we define a recursive function,we also define a stopping criteria when it stops to call itself.so there is no limit on calling a recursive function but it has stopping criteria.
and recursion about main function, it cannot be called as it is illegal to call main function inside main because it goes to infinite loop. like main ->main->main->but after that it will again call main function and never reach to stopping criteria so it will restart the program again and again.

answer Mar 8, 2016 by Shivam Kumar Pandey
Similar Questions
+4 votes

Addition to this,

Can we consider "a car a man a maraca" as palindrome string?
Click here To see similar kind of palindrome strings,
Are they really a palindrome?

+2 votes

I need to write a function to flat nested lists as this one:

[[1,2,3],4,5,[6,[7,8]]]

To the result:

[1,2,3,4,5,6,7,8]

So I searched for example code and I found this one that uses recursion (that I don't understand):

def flatten(l):
 ret = []
 for i in l:
 if isinstance(i, list) or isinstance(i, tuple):
 ret.extend(flatten(i)) #How is flatten(i) evaluated?
 else:
 ret.append(i)
 return ret

So I know what recursion is, but I don't know how is

 flatten(i)

evaluated, what value does it returns?

...