May 31, 2023
program to use factorial number in C Language
#include <stdio.h>
int main()
{
int n, num;
long fact = 1;
printf("enter a number : ");
scanf("%d", &n);
num = n;
if (n < 0)
{
printf("no factorial of negative number\n");
}
else
{
while (n > 1)
{
fact *= n;
n--;
}
printf("factorial of %d=%d\n", num, fact);
}
return 0;
}
output
enter a number : 4
factorial of 4 = 24
by : Nadeem Khan
Quick Summary:
Factorial of a positive (number) is the sum of multiplication of all the integers smaller than that positive integer . For example , factorial of 4 is 4*3*2*1 which equals to 24