Home >>c programs >Factorial Number Program in C

Factorial Number Program in C

Factorial Number Program in C

Factorial Number program in C is denoted by the symbol ‘!’. Factorial of a number is defined as the product of all the numbers and all positive descending integers .

The natural number (non-negative integers) which are greater than zero are used for factorial program in C.

Factorial of 5 and 3 are like this

5!=5*4*3*2*1
3!=3*2*1

Let's take an example of Factorial Number:

#include<stdio.h>  
int main()    
{    
 int i,f=1,num;    
 printf("Enter Your  number to print factorial: ");    
  scanf("%d",&num);    
    for(i=1;i<=num;i++)
	{    
      f=f*i;    
	}    
  printf("Factorial number =%d",f);    
return 0;  
}   
Output :
Enter Your number to print factorial: 4
Factorial number =24
Output :
Enter Your number to print factorial: 5
Factorial number =120

No Sidebar ads