Factorial Program in C - C Program to Find Factorial



 c program to find factorial

Learn C - C tutorial - c program to find factorial - C examples - C programs

C Program to Find Factorial

  • There are three methods to find and print factorial of a number.
  • Three methods are, the first one uses for loop, the second uses a function to find factorial and the third uses recursion.
  • A factorial is product of all the numbers from 1 to n.
  • Factorial is represented using '!'.

Sample Code

#include<stdio.h>
int main()
{
    int i,f=1,n=6;
    printf("Natural number:6 ");
    for(i=1; i<=n; i++)
        f = f * i;
    printf("\n%d!=%d\n", n, f);
    return 0;
}

Output

Natural number:6 
6! = 720


View More Quick Examples


Related Searches to Factorial Program in C - C Program to Find Factorial