C program to find factorial of a given number using recursion

#include<stdio.h>
int fac(int n);
int main( )
{
     int n, fact;
    
     printf("Enter a number");
     scanf("%d",&n);

     fact=fac(n);


     printf("Factorial of number %d is %d", n, fact);


  return 0;

}

int fac(int n)

{
     if(n==0 || n==1)
         return 1;
   
     else
          return(n*fac(n-1));
}



Post a Comment

0 Comments