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 

#include<stdio.h>
#include<conio.h>
void main()
{
long num, i,fact=1;
clrscr();
printf("Enter a number:");
scanf("%ld",&num);
for(i=num; i>=1; i--)
  { fact*=i;
  }
printf("The factorial of the number %ld is %ld",num,fact);
 getch();
}

Output:

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

People Also Looking For:

Leave a Reply

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