Resurcion
The usual method is to make the recursive call part of an if statement.
Wtih luck or foresight, tesst eventually becomes false, and the chain of calls is broken.
void recurs(argumentlist) {
statements1
if (test)
recurs(arguments)
statements2
}
After going into five levels of recursion, the program then has to back out through the same five levels.