Recursion in C

Comments · 12 Views

A function which itself calls is known as a recursive function. And, the strategy is called recursion.

Recursion in C is the mechanism of repeating objects in a similar manner to themselves. When a program allows you to call a function inside the same function in programming languages, that function is called a recursive call. Recursion can result in an intuitive, very simple, elegant code to follow. It may also require the use of a very large amount of memory if the recursion is too long.

A function which itself calls is known as a recursive function. And, the strategy is called recursion.

Recursion can not be extended to all of the problems, but for the tasks that can be described in terms of similar subtasks, it is more useful. For example, recursion can be applied to problem sorting, searching, and traversing.

C program helps you to do such a function calling inside a specific function, i.e., a recursion. However when introducing this definition of recursion, you must be careful to specify an exit or terminate condition from this recursive function, or else it will lead to an infinite loop, so make sure the condition is set within your program.

Comments