What is recursion
Recursion is the process of a function calling itself repeatedly till the given condition is satisfied. A function that calls itself directly or indirectly is called a recursive function and such kind of function calls are called recursive calls.
In computing, recursion provides powerful alternative for performing repetitive tasks. In fact, few programming languages do not explicitly support looping constructs instead rely on recursion.
In depth recursion means when you call a function by its name for the time then the function call its name inside its definition to perform repetitive task similar as loop until the condition is true, for using recursion we should know the starting and end point of the task or operation.
Recursive Functions in C
In C, a function that calls itself is called Recursive Function. The recursive functions contain a call to themselves somewhere in the function body. Moreover, a functions can contain multiple recursive calls.
Syntax
type function_name (args) {
// function statements
// base condition
// recursion case (recursive call)
}
this is the basic syntax to perform recursion in function.
Recursion is an important topic in the study of data structure and algorithm
Top comments (0)