Friday, May 13, 2016

Factorial Function Using Recursion.





#include<stdio.h>

int main()
{
 int fact(int ) ;
        int r,n;
        printf("Enter the Value of n\n");
        scanf("%d",&n);
        r=fact(n);
        printf("Factorial value = %d\n",r);
       return 0 ;
}

int fact (int x)
{
  int f;
   if (x==0||x==1)
       return(1);
   else
      f = x*fact(x-1);
      return(f);
}


Share this

0 Comment to "Factorial Function Using Recursion."

Post a Comment