0
1.3kviews
What is function? Write a C program to calculate factorial of a given number.
1 Answer
written 2.1 years ago by |
Function:
C program to find factorial :-
void factorial (int)
void main()
{
int number;
int fact;
printf(“Enter a number:”)
scanf(“%d”, &number);
fact=factorial(number);
printf(“factorial of %d is %d \n”number,fact);
}
void factorial(int n)
{
if (n==0)
return 1;
else
return (n*factorial(n-1));
}