Factorial of a number in C Programming

Image result for c programming

Factorial of a number in C Programming
Code:
  #include<stdio.h>
int factorial(int n);
int main()
{
  int n,f;
  scanf("%d",&n);
  f=factorial(n);
  printf("%d",f);
  return 0;
}
int factorial(int n)
{
  int i,sum=1;
  for(i=1;i<=n;i++)
  {
    sum=sum*i;
}
  return sum;
}
  

No comments