WAP to find factorial using recursive of function

#include<conio.h>
#include<stdio.h>
int fact(int);

void main()
{
int n,f;
clrscr();

printf("\nEnter the number :-");
scanf("%d",&n);

f=fact(n);

printf("\nThe Factorial=%d",f);

getch();

}

int fact(int n)
{
 int f=1;
 if(n==1)
 {
 return(f);

 }
 else
 {
 f=n*fact(n-1);
 return(f);
 }
 }

No comments:

Post a Comment