Write a program in C to calculate the factorial of a number

By | October 4, 2021
Factorial program in C

Here in this program, we will code to calculate the factorial of a number entered by the user.

What is a factorial?

It is a mathematic concept mostly used in permutation, combination, and probability, its symbol is (!). In simple words, a factorial says multiply all whole numbers from our chose number down to 1.

For example, if we say 5 factorials in math it would be represented by 5! and evaluated by 5*4*3*2*1 = 120.

By convention, the 0! is equal to 1.

Use/Application of Factorial

  • In recursion we use Factorial
  • In permutation
  • In combination
  • In probability distribution

C statements we will use in the program:

  • For loop
  • * (multiplication arithmetic operator) 

Factorial Program in C Language 

void main()
long num, i,fact=1;
printf("Enter a number:");
for(i=num; i>=1; i--)
  { fact*=i;
printf("The factorial of the number %ld is %ld",num,fact);


Enter a number:10
The factorial of the number 10 is 3628800

People are also reading:

Leave a Reply

Your email address will not be published. Required fields are marked *