CODE FOR FACTORAIL (RECURSION)

#include<stdio.h>
#include<conio.h>
void main()
{
 int a,f;
 clrscr();
 printf("Enter the number : ");
 scanf("%d",&a);
 f=fact(a);
 printf("The factorial of %d is %d",a,f);
 getch();
}
int fact(n)
{  int f=1;
  if(n!=0)
  {
   f=n*fact(n-1);
  }
  return f;
}

Comments

Popular posts from this blog

Code for BUBBLE Sort

Code for Circular Linked List c-programing

Code for SELECTION Sort in C-Programming