C Program to find the factorial of a given number using recursion

Program

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

Output

Enter a number to find the factorial:
5
Factorial of 5 is 120