Find Factorial of a number using C programming
In mathematics, the factorial of a non-negative integer n, denoted by n! is the product of all positive integers less than or equal to n. For example,
We are going to find out factorial by using C programming. Let’s see the code
Now let’s see the output
In mathematics, the factorial of a non-negative integer n, denoted by n! is the product of all positive integers less than or equal to n. For example,
5! = 5 X 4 X 3 X 2 X 1 = 120.
Also factorial of 0! Is 1.We are going to find out factorial by using C programming. Let’s see the code
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k=1;
printf("Enter your number");
scanf("%d",&i);
for(j=1;j<=i;j++)
{
k=k*j;
}
printf("Factorial of number %d is %d",i,k);
}
In above program we use for loop to calculate the factorial. When we insert any value in this loop that value will be multiplied by all other integer value less than inserted value until loop ends.#include<conio.h>
void main()
{
int i,j,k=1;
printf("Enter your number");
scanf("%d",&i);
for(j=1;j<=i;j++)
{
k=k*j;
}
printf("Factorial of number %d is %d",i,k);
}
Now let’s see the output
Enter your number 5
Factorial of number 5 is 120
Factorial of number 5 is 120

ReplyDeleteVery informative article.Thank you author for posting this kind of article .
http://www.wikitechy.com/view-article/c-program-to-find-factorial-of-a-number-with-example-and-explanation
Both are really good,
Cheers,
Venkat