Write a program to calculate factorial of a number in C language usingfor loop

Write a program to calculate factorial of a number in C language using for loop


This is a famous C language program while learning C language programming. Many times factorial of a number program is asked in exams at board levels and university levels.
factorial of a number

factorial of a number 



Factorial of a number can be calculated mathematically by multiplying all the natural numbers starting from 1 up to the number, whose factorial is to be calculated.

For example : Factorial of 4 can be calculated by multiplying natural numbers from 1 to 4, like 1x2x3x4=24

void main()
{
int f=1, i, n;
printf("Enter a positive integer");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
f=f*i;
}
printf("Factorial = %d", f);
}