#include <stdio.h>
#include <conio.h>
int fact(int);
int main()
{
int no, factorial;
printf("Enter a number: \n");
scanf("%d",&no);
factorial=fact(no);
printf("Factorial of (%d) is %d\n",no,factorial);
getch();
return 0;
}
int fact(int n)
{
int i,f=1;
for(i=1;i<=n;i++)
{
f=f*i;
}
return f;
}
Enter a number:
5
Factorial of (5) is 120
--------------------------------
Process exited after 5.362 seconds with return value 0
Press any key to continue . . .