This C Program print the factorial of a given number. A factorial is product of all the numbers from 1 to n, where n is the user specified number. This program find the product of all the number from 1 to the user specified number.
Here is source code of the C program to print the factorial of a given number. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
* C program to find the factorial of a given number
int i, fact = 1, num;
printf("Enter the number \n");
if (num <= 0)
fact = 1;
for (i = 1; i <= num; i++)
fact = fact * i;
printf("Factorial of %d = %5d\n", num, fact);
$ cc pgm79.c $ a.out Enter the number 10 Factorial of 10 = 3628800
Sanfoundry Global Education & Learning Series – 1000 C Programs.