Write a recursive program to find the factorial of a given number.

#include<stdio.h>
long fact(int);
int main()
{
int x;
printf("enter the number:");
scanf("%d",&x);
printf("the factorial of %d is %ld",x,fact(x));
}
long fact(int n)
{
  if(n==0)
  return (1);
  else return (n*fact(n-1));
}

Comments

Popular posts from this blog