October 2011
Beginner to intermediate
1200 pages
35h 33m
English
If a recursive function calls itself, then the newly called function calls itself, and so on, ad infinitum unless the code includes something to terminate the chain of calls. The usual method is to make the recursive call part of an if statement. For example, a type void recursive function called recurs() can have a form like this:
void recurs(argumentlist){ statements1 if (test) recurs(arguments) statements2}
With luck or foresight, test eventually becomes false, and the chain of calls is broken.
Recursive calls produce an intriguing chain of events. As long as the if statement remains true, each call to recurs() executes statements1 and then invokes a new incarnation of recurs() ...
Read now
Unlock full access