The factorial of a integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,
Factorial of 5 = 5! = 5 X 4 X 3 X 2 X 1 = 120
The value of 0! is 1, according to the convention for an empty product.
So, given below is Program in C To find Factorial of a given number.
PROGRAM CODE :
#include<stdio.h>
#include<conio.h>
void main()
{
int k,n,fact = 1;
clrscr();
printf("----->FACTORIAL<-----\n");
printf("Enter a number: ");
scanf("%d",&n);
for(k=1;k<=n;k++)
fact=fact*k;
printf("\nFactorial of %d = %d \n",n,fact);
getch();
}
0 comments:
Post a Comment