C Program to find factorial of a number using functions
Program
#include<stdio.h>
int fact(int);
void main()
{
int num;
printf("Enter the number to find the factorial:\t");
scanf("%d", &num);
printf("Factorial is %d\n", fact(num));
}
int fact(int num)
{
int i, factor = 1;
i = 1;
while(i <= num)
{
factor = factor * i;
i++;
}
return factor;
}
Output
Enter the number to find the factorial: 7
Factorial is 5040