Tuesday, September 27, 2011

C Program To Find Factorial Of A Number Using Recursive Function

Factorial(Recursive)


Variables used
num-The number
facto-Factorial


Program
#include<stdio.h>
main()
{
int num ,facto ;
int fact(int);
printf("Enter the Number");
scanf ("%d",&num);
facto=fact(num);
printf("Factorial of Number=%d",facto);
}
int fact(int x)
{
int y;
if(x==1)
return 1;
else
{
y= x * fact(int x-1);
return y;
}
}

No comments:

Post a Comment