#include<stdio.h>
int main()
{
int k, n;
int fact = 1;
printf("Enter an input number to find its factorial \n");
scanf("%d", &n);
if(n==0)
{
printf("Entered number must be above zero \n");
}
else
{
for (k = 1; k <= n; k++)
fact = fact * k;
printf("Factorial of the given number is %d = %d\n", n, fact);
}
return 0;
}
OUTPUT:
Enter an input number to find its factorial
4
Factorial of the given number is 4 = 24
Enter an input number to find its factorial
9
Factorial of the given number is 9 = 362880
int main()
{
int k, n;
int fact = 1;
printf("Enter an input number to find its factorial \n");
scanf("%d", &n);
if(n==0)
{
printf("Entered number must be above zero \n");
}
else
{
for (k = 1; k <= n; k++)
fact = fact * k;
printf("Factorial of the given number is %d = %d\n", n, fact);
}
return 0;
}
OUTPUT:
Enter an input number to find its factorial
4
Factorial of the given number is 4 = 24
Enter an input number to find its factorial
9
Factorial of the given number is 9 = 362880
No comments:
Post a Comment