C Program to Calculate Factorial Using Function

0
5
digitalample eye
Write a program to calculate the factorial of entered number.
Write a C program to calculate the factorial of entered number using recursion.
C Program to calculate the factorial of number using function.
C Program to Calculate Factorial of the Value.

C Code

#include<stdio.h>
#include<conio.h>
long int factorial(int);
void main()
{
int n;
long int fact;
printf("Enter number:");
scanf("%d",&n);
fact=factorial(n);
printf("Factorial number of %d=%ld",fact);
getch();
}
long int factorial(int n)
{
long int fact=1;
for(i=1; i<n; i++)
fact=fact*i;
return fact;
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here