- Recursion is the process of repeating items in a self-similar way. Same
applies in programming languages as well where if a programming allows
you to call a function inside the same function that is called recursive
call of the function as follows.
here is a basic example about how recursion works
This program ends when we've counted to twenty, or more precisely, when count is
no longer less than twenty. This is a good base case because it means that if we
have an input greater than twenty, we'll stop immediately. If we'd chosen to
stop when count equaled twenty, then if the function were called with the input 21, it would run out of memory before stopping.
By the way, i wrote the function name as count_to_ten ., actually it should be count_to_twenty . but its just a name given by us, so i guess its okay. i forgot to modify that one
source :
Tutorialspoint : http://www.tutorialspoint.com/cprogramming/c_recursion.htm
Cprogramming : http://www.cprogramming.com/tutorial/c/lesson16.html
Hope this basic recursion example helps.
Peace!