C Program to Find Factorial of a Number Using Function

C Program to Find Factorial of a Number Using Function. In this program, we can find the factorial of a number using function as a beginner in a c programming language.

Factorial Number Definition in C

The mathematical definition of n! = n * (n – 1) * (n – 2) * (n – 3) is the operation of multiplying any natural number with all the natural numbers that are smaller than it. 

Finally, factorial is used to ask how many different ways you can arrange or order a set number of items.

For Loop in C

A for loop is a repetition control structure that allows us to create a loop that runs a set number of times. 

The loop allows us to perform an arbitrary number of steps in a single line. 

A for-loop is a control flow statement in computer science that specifies iteration and allows code to be executed repeatedly. 

The name for-loop comes from the word for, which is used as a keyword to introduce a for-loop in many programming languages.

#include <stdio.h>
int fact(int);
int main()
{
int no,factorial;
printf("Enter The Number\n");
scanf("%d",&no);
factorial=fact(no);
printf("Factorial Number is = %d\n",factorial);
}
int fact(int n)
{
int i,f=1;
for(i=1;i<=n;i++)
{
f=f*i;
}
return f;
}

Output:

Enter The Number
5
Factorial Number is= 120