PROGRAM
#include<stdio.h>
int fact(int);
int fact(int);
void
main(){
intnum,f;
printf("\nEnter a number: ");
scanf("%d",&num);
f=fact(num);
printf("\nFactorial of %d is: %d",num,f);
}
int
fact(int n){
if(n==1)
return 1;
else
return(n*fact(n-1));
}
0 Comment "Write a c program for factorial of a given number using recursion."
Post a Comment