Recursion is a programming technique that allows the programmer to express operations in terms of themselves. In C, this takes the form of a function that calls itself. A useful way to think of recursive functions is to imagine them as a process being performed where one of the instructions is to "repeat the process".

 

#include<stdio.h>
#include<conio.h>
int f=1;//initialize to 1
int fact(int i)
{
    if(i==0|| i==1)
    {
        return f;
    }
    f=i*fact(i-1);
    return f;
}
void main()
{
   int n,ans;
   clrscr();
   printf("Enter number to find factorial:");
   scanf("%d",&n);
   ans=fact(n);
   printf("Factorial of %d is %d",n,ans);
   getch();

}