P162. Using recursion function design a program for factorial finding .
#include<stdio.h>
int
fact(int);
void
main()
{
int num,r;
printf("Enter a number : ");
scanf("%d",&num);
r=fact(num);
printf("%d",r);
}
int
fact(int nu)
{
if(nu)
{
return nu*fact(nu-1);
}
else
return 1;
}
Comments
Post a Comment