C Program Factorial with Recursion.

Ram Pothuraju
This program is for Factorial using recursive function. 


#include<stdio.h>
#include<conio.h>
int sum=1;
int fact(int x)
{
if(x==0)
return sum;
sum=x*fact(x-1);
}

void main()
{
int n;
clrscr();
printf("Enter the value of n\n");
scanf("%d",&n);
printf("\nFactorial of the number is : %d",fact(n));
getch();
}
Tags

Post a Comment

0Comments

Post a Comment (0)