Factorial is a product of all positive numbers from 1 to n
, here n
is a number to find factorial.
Ex: 5! = 5*4*3*2*1
You can also check factorial of a program using for loop, factorial of a program using Recursion, Flowchart to Find Factorial of a Number and Factorial of a number using Functions in C.
PROGRAM:
#include <stdio.h>
int main()
{
int n,i,f;
f=i=1;
printf("Enter a Number to Find Factorial: ");
scanf("%d",&n);
while(i<=n)
{
f*=i;
i++;
}
printf("The Factorial of %d is : %d",n,f);
return 0;
}
OUTPUT:
Enter a Number to Find Factorial: 5 The Factorial of 5 is : 120
C Program to Find Factorial of a Number using Recursion
Compute Factorial of Large Numbers using C