C program to find factorial using recursion
Program:
#include <stdio.h>
int fact(int n);
void main()
{
int factorial, num=5;
factorial = fact(num);
printf("factorial = %d",factorial);
}
int fact(int n)
{
if(n==0 || n==1)
return 1;
else
return n*fact(n-1);
}
Output:
factorial = 120
Drafted on 🌏 by,
Jal
☮
peace
Comments
Post a Comment