C program to find the factorial of n numbers: In this program we will calculate the factorial of a number using for loop.
Code for C program to find the factorial of n numbers
#include<stdio.h>
#include<conio.h>
int main()
{
int n, i, fact = 1;
printf("Enter an integer: ");
scanf("%d", &n);
if (n < 0)
{
printf("Error! Factorial of a negative number doesn't exist.");
}
else
{
for (i = 1; i<= n; ++i)
{
fact *= i;
}
printf("Factorial of %d = %d", n, fact);
}
return 0;
}
Output
Enter an integer: 10
Factorial of 10 = 3628800