programming-examples/c/Functions/C Program to find factorial of a number using functions.c

18 lines
355 B
C
Raw Normal View History

2019-11-15 12:59:38 +01:00
#include<stdio.h>
int findFactorial(int);
int main()
{
int i,factorial,num;
printf("Enter a number: ");
scanf("%d",&num);
factorial = findFactorial(num);
printf("Factorial of %d is: %d",num,factorial);
return 0;
}
int findFactorial(int num)
{
int i,f=1;
for(i=1; i<=num; i++)
f=f*i;
return f;
}