Sitesbay.com
Factorial Program
Factorial Program in C
Hitesh Kumar
SITESBAY.COM
Sitesbay.com
Factorial Program in C
Factorial of n is the product of all positive descending integers. For example:
5! = 5*4*3*2*1 = 120. Here we write Factorial Program in C
#include<stdio.h>
#include<conio.h>
void main()
{
int fact,i,n;
fact = 1;
printf("Enter any Number: ");
scanf("%d" , &n);
for(i = 1; i <= n; i++)
{
fact = fact*i;
}
printf("Factorial of %d is %d", n , fact);
getch();
}
Output:
Enter any Number: 5
Factorial of 5 is 120

Factorial Program in C

  • 1.
  • 2.
    Sitesbay.com Factorial Program inC Factorial of n is the product of all positive descending integers. For example: 5! = 5*4*3*2*1 = 120. Here we write Factorial Program in C #include<stdio.h> #include<conio.h> void main() { int fact,i,n; fact = 1; printf("Enter any Number: "); scanf("%d" , &n); for(i = 1; i <= n; i++) { fact = fact*i; } printf("Factorial of %d is %d", n , fact); getch(); } Output: Enter any Number: 5 Factorial of 5 is 120