HOME

Friday, March 20, 2015

C PROGRAM TO FIND THE FACTORIAL OF GIVEN NUMBER USING RECURSIVE FUNCTION

#include<stdio.h>
#include<conio.h>
int fact(int n);
main()
{
int n;
printf("enter the number n:\n");
scanf("%d",&n);
printf("the factorial %d is %d",n,fact(n));
}
int fact(int a)
{
if(a==1)
{
return 1;
}
else
{
return a*fact(a-1);
}
}

No comments:

Post a Comment