What is Recursion in C?

The recursion is a programming technique to allow programmers to express the operation themselves. If a program allows you to call a function inside the same function, then it is called a recursive call of the function. The recursion is similar to a loop because it repeats the same code, and in some ways it is similar to looping. On the other hand, recursion makes it easier to express ideas in which the result of the recursion.
On to call itself. But while using recursion, programmers need to be careful to define an exit condition from the function, otherwise it will go into an infinite loop.
Recursive functions is applied to solve some mathematical problems, such as calculating the factorial of a number, generating Fibonacci series, etc.
Syntax of Recution
void recursion()
{
recursion();
/* function calls itself */
}
int main()
{ recursion();
}
Example of recursion.
Program to generates the Fibonacci series for a given number using a recursive function.
#include <stdio.h> int fibonacci(int i) { if(i == 0) { return 0; } if(i == 1) { return 1; } return fibonacci(i-1) + fibonacci(i-2); } int main() { int i; for (i = 0; i < 10; i++) { printf("%d\t\n", fibonacci(i)); } return 0; }