Recursion Function in C


Recursion is the process which comes into existence when a function calls a copy of itself to work on a smaller problem. Any function which calls itself is called recursive function, and such function calls are called recursive calls. Recursion involves several numbers of recursive calls. However, it is important to impose a termination condition of recursion. Recursion code is shorter than iterative code however it is difficult to understand.

Source Code

//Recursion Function in C Programming
#include<stdio.h>
/*
    5!
    1*2*3*4*5
*/
 
int factorial(int i) //5
{
    if(i<=1){
        return 1;
    }
    return i*factorial(i-1);  //5*4*3*2*1
}
 
int main()
{
    printf("Factorial : %d",factorial(5));
    return 0;
}
 
To download raw file Click Here

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes