/* C Program to find Factorial of given Number using Function*/
#include <stdio.h>
//#include<conio.h>
int main()
{
int num;
//clrscr();
printf("\n >> PROGRAM TO FIND FACTORIAL OF GIVEN NUMBER
using Function <<\n");
printf("\n Enter the Number whose Factorial you want: ");
scanf("%d",&num);
printf("\n The factorial of %d is %d.\n\n",
num,factorial(num));
//factorial(num) prints the value returned by the function
//getch();
return 0;
}
int factorial(num1)
{
int i,fact=1;
for(i=num1; i>=2 ; i--)
{
fact = fact * i;
}
return fact; //returning fact to main function
}
---------------------------------------------------------------------------------------------
Sample Output:
( using GNU GCC Compiler with code::blocks IDE, hence no need of clrscr(); and getch(); )