Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
338 B
1
Indexable
Never
//recursive function
#include<stdio.h>
#include<string.h>

int fact(int);
void main(){

int n,factorial;
printf("Enter a number: \n");
scanf("%d",&n);

factorial = fact(n);

printf("Factorial =%d",factorial);

}
int fact(int n){
int res=1,i;
if(n==1){
    return 1;
}
else {
    res=n*fact(n-1);
}
return res;
}
Leave a Comment