C program to find the factorial of n numbers

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

Read: C Program To Find The Fibonacci Series


If You Like This Page Then Make Sure To Follow Us on Facebook, G News and Subscribe Our YouTube Channel. We will provide you updates daily.
Shares
facebook sharing button Share
twitter sharing button Tweet
whatsapp sharing button Share
telegram sharing button Share
pinterest sharing button Pin

Leave a Comment