Find Factorial using Recursion | C Program:
Write a C Program to Find Factorial User given using Recursion :
About factorial:
5! = 5!x4!x3!x2!x1! = 120
Code:
#include<stdio.h>
void main()
{
int facto(int);
int n,b;
printf("Enter a range of factorial:\n");
scanf("%d",&n);
b=facto(n);
printf("\nThe factorial of %d is %d",n,b);
}
int facto(int n)
{
if(n==1)
return n;
else
n=n*facto(n-1);
return n;
}
Comments
Post a Comment
Give your feedback!
DO NOT SPAM !!
NO THIRD PARTY PROMOTIONAL LINK !!!! (else comment will be deleted.)