Factorial of a number(C)
CODE:-
#include<stdio.h>
#include<conio.h>
long int factorial(int n);
int main()
{
int n;
printf("Enter the digit:\n");
scanf("%d",&n);
printf("Factorial of %d is %d",n,factorial(n));
getch();
}
long int factorial(int n)
{
if(n<=1)
{
return(01);
}
else
{
n=n*factorial(n-1);
return(n);
}
}
OUTPUT:-
No comments:
Post a Comment