programming-examples/c/Functions/C Program to Print the Factorial of a given Number.c
2019-11-15 12:59:38 +01:00

21 lines
426 B
C

/*
* C program to find the factorial of a given number
*/
#include <stdio.h>
void main()
{
int i, fact = 1, num;
printf("Enter the number \n");
scanf("%d", &num);
if (num <= 0)
fact = 1;
else
{
for (i = 1; i <= num; i++)
{
fact = fact * i;
}
}
printf("Factorial of %d = %5d\n", num, fact);
}