//write a 'C' program to calculate the factorial of a number using function.
#include<stdio.h>
void main()
{
int ans, n;
int fact(int n);
printf("Enter the number:- ");
scanf("%d", &n);
ans=fact(n);
printf("the factorial of %d is %d",n,ans);
}
int fact(int n)
{
int res=1, i;
for(i=n; i>=1; i--)
res=res*i;
return(res);
}