#include
#include
void main()
{
int n;
long int fact(int);/*Prototype*/
clrscr();
printf("Enter value to Find Factorial : ");
scanf("%d",&n);
printf("Factorial of %d is %d.",n,fact(n));
getch();
}
long int fact(int n)
{
if(n<=1) return(1); else return(n*fact(n-1)); }
Output
Enter value to Find Factorial : 5
Factorial of 5 is 120.
No comments:
Post a Comment