Write a C program to find factorial of positive integer using recursive function.
Write a C program to find factorial of positive integer using recursive function
#include<stdio.h>
int fact(int n)
{
if(n==0)
return(1);
else
return(n*fact(n-1));
}
void main()
{
int n;
printf(“Enter an integer\n”);
scanf(“%d”,&n);
printf(“Factorial of %d is %d\n”,n,fact(n));
}
Comments
Post a Comment