Write a C Program to find factorial of number

Factorial: using symbol “! ”

Mathematical Example : 5! = 120 (5*4*3*2*1=120))

 

Program:

#include<stdio.h> 
int main() 
{ 
int i,fact,number; 
printf("Enter a number: "); 
scanf("%d",&num); 
for(i=1,fact=1;i<=num;i++){ or (for(i=num,fact=1;i<=1;i--))
fact=fact*i; 
} 
printf("Factorial of %d is: %d",num,fact); 
return 0; 
} 
Output:

Enter a number: 9
Factorial of 9 is: 362880
Scroll to Top