Thursday, November 22, 2012

C PROGRAM FOR FACTORIAL USING RECURSION


/* C PROGRAM FOR  FACTORIAL USING RECURSION */

#include<stdio.h>
#include<conio.h>

void main()
{
      int n,f;
      int fact(int);
      clrscr();
      printf("\n\t\t FACTORIAL USING RECURSION");
      printf("\n\t\t ~~~~~~~~~~~~~~~~~~~~~~~~~");
      printf("\n Enter the numbers:");
      scanf("%d",&n);
      f=fact(n);
      printf("\n The factorial :%d",f);
      getch();
 }

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






















OUTPUT:

              
                     FACTORIAL USING RECURSION



Enter the numbers: 5

 The factorial: 120






0 comments:

Post a Comment