Untitled

 avatar
unknown
plain_text
a year ago
338 B
4
Indexable
//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;
}
Editor is loading...
Leave a Comment