Thursday, 19 December 2019

Factorial of a number using recursion

#include<stdio.h>
#include<conio.h>
int fact(int);
int main()
{
int i,n,f=1;
printf("enter the number\n");
scanf("%d",&n);
printf("The factiorial is %d\n",fact(n));
     getch();
return 0;
}
int fact(int n)

     int f;
     if(n==0||n==1)
     return n;
     else
return(n*fact(n-1));
  }

No comments:

Post a Comment

Convey your thoughts to authors.