source code: recfact.c
#include<stdio.h>
int recfact(int n)
{
int f=1;
if(n==0)
return 1;
else
f=n*recfact(n-1);
return f;
}
int main()
{
int n,fv;
//clrscr();
printf(" enter any no: \n");
scanf("%d",&n);
fv=recfact(n);
printf(" factorial value: %d ",fv);
//getch();
return 0;
}
output:
enter any no: 6
factorial value: 720
0 Comments
Post a Comment