Program for Factorial in C

Here you will get a program for factorial in C.

We can discover factorial of any number by increasing it with every one of the numbers beneath it.

For instance, the factorial of 3 will be 6 (3 * 2 * 1).

Program

#include<stdio.h>
 
int main()
{
	long i,n,fac=1;
	printf("Enter value of n:");
	scanf("%ld",&n);
	
	for(i=n;i>=1;--i)
		fac*=i;
		
	printf("\nFactorial of %ld is %ld",n,fac);
 
	return 0;
}

Output

Enter value of n:4

Factorial of 4 is 24

Leave a Comment

error: Alert: Content is protected!!