PROGRAM:
#include
#include
void main()
{
int a,fact=1,i;
printf("\nEnter the number: ");
scanf("%d",&a);
for(i=1; i<=a;i++)
{
fact=fact*i;
}
printf("The factorial of %d is %d",a,fact);
getch();
}
OUTPUT:
EXPLANATION:
The above program will the multiply the each iteration with previous iteration until the give number
#include
#include
void main()
{
int a,fact=1,i;
printf("\nEnter the number: ");
scanf("%d",&a);
for(i=1; i<=a;i++)
{
fact=fact*i;
}
printf("The factorial of %d is %d",a,fact);
getch();
}
OUTPUT:
EXPLANATION:
The above program will the multiply the each iteration with previous iteration until the give number
No comments:
Post a Comment