C Program to Find Factorial of a Number Using While Loop

C Program to find factorial of a number using while loop. Using this program we can execute the find factorial of a number in the c programming language for beginners.

Factorial Number in C

The operation of multiplying any natural number with all the natural numbers that are smaller than it is 

defined as n! = n * (n – 1) * (n – 2) * (n – 3). 

Finally, factorial is used to determine how many different ways a set number of items can be arranged or ordered. 

The factorial of n is the product of all positive descending integers. 

The sum of all positive integers less than or equal to a given positive integer, denoted by that integer and an exclamation point, is denoted by n!

While Loop in C

A “While” Loop is used to repeat a block of code an unknown number of times until it meets a condition. 

In C programming, a while loop executes a target statement repeatedly as long as a condition is true. 

Any of the loop control structures can use the continue keyword. It causes the loop to jump to the next iteration of the loop right away.

C Program to Find Factorial of a Number Using While Loop

#include <stdio.h>
int main()
{
int n,i,f;
f=i=1;
printf("Enter The Number");
scanf("%d",&n);
while(i<=n)
{
f*=i;
i++;
}
printf("The Factorial of %d is : %d",n,f);
return 0;
}

Output:

Enter The Number4
The Factorial of 4 is : 24