C Program Find Factorial of N

By | March 7, 2020

C Program Find Factorial of N

Output

Enter n number to calculate factorial=5
Factorial of 5 is 120

C Code / C Program To Find Factorial of a number N

#include<stdio.h>

int main()
{
    int n, i;
	
	long fact=1;
    
	printf("Enter n number to calculate factorial=");
	scanf("%d", &n);
	
	for(i=1;i<=n;i++)
	  fact = fact * i;
	
	printf("Factorial of %d is %ld", n, fact);
	
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *