Write a Recursive Program to find the Factorial of a Number.



In this post, we will make a program in C to find the factorial of a number using the Recursive Program. 

Code

#include <stdio.h>
int factorial(signed int i){
    if (i<=1)
{
    return 1;
} 
 return i* factorial(i-1);
}
int i;
int main(){
    printf("Enter any mumber");
    scanf("%d", &i);
    printf("Factorial of %d is %d\n",i, factorial(i));
    return 0;
}

Output


Enter any mumber99
Factorial of 99 is 0

Post a Comment

Previous Post Next Post