C Programs / Factorial C Program

Program
#include 
void main()
{
int n,i,factorial=1;
printf("Enter a number : "); 
scanf("%d", &n);
for(i=1; i<=n; i++) 
factorial = factorial * i;
printf("Factorial value of %d = %d",n,factorial);
}
Input Enter a number : 5
Output Factorial value of 5 = 120


Home     Back