Here is the 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 factorial of a given number using recursion
printf("Enter a number to find it's Factorial: ");
if (num < 0)
printf("Factorial of negative number not possible\n");
result = factorial(num);
printf("The Factorial of %d is %d.\n", num, result);
int factorial(int num)
if (num == 0 || num == 1)
return(num * factorial(num - 1));
$ cc pgm5.c $ a.out Enter a number to find it's Factorial: 6 The Factorial of 6 is 720.
Sanfoundry Global Education & Learning Series – 1000 C Programs.