Write a c program to find out factorial of given number using function recursion.



void main()
{
long num,f;
clrscr();
printf("Input a number: ");
scanf("%ld",&num);
f=fact(num);
printf("\nFactorial is %ld",f);
getch();
}
int fact(long n)
{
if(n==0)
return 1;
else
return(n*fact(n-1));
}

2 comments:

  1. what is we need to find the factorial of 100..

    ReplyDelete
  2. wil this prgm work? fact function is not declared before main na

    ReplyDelete