Do you know how to find the factorial of a given number? The factorial of a given number can be found by calculating the product of the sequence of numbers till the number, beginning from 1.
As an example, factorial of 5 can be found as
5*4*3*2*1
which is equal to 120
Similarly, factorial of 6 is
6*5*4*3*2*1
which is equal to 720
How do we program this in ‘C’? Let us see below:
// Online C compiler to run C program online
#include <stdio.h>
int main() {
// Write C code here
printf("Finding the factorial of a number C\n");
int i, j, k=1;
printf("Enter the number whose factorial you want to find\n");
scanf("%d", &i);
for (j=1; j<=i; j++)
{
k=k*j;
}
printf("%d", k);
return 0;
}

This is the result you will get when you run the program in any compiler.
Finding the factorial of a number C
Enter the number whose factorial you want to find
6
720
=== Code Execution Successful ===
You can try running the above code by means of this online compiler
This is the next post for the BlogchatterHalfMarathon challenge by @blogchatter
(Visited 35 times, 1 visits today)
I understood factorial, but not the coding because I have no idea about the latter.
I could explain more in another post…:) Thanks for reading…
I also want to know more about coding
Sure…I will try to write more in subsequent challenges…