C Program to calculate Factorial. In this program we will take a number as an input and calculate the factorial.
In the following program we calculate Factorial of a given number.
#include<stdio.h>
void main()
{
int x,i,res=1;
printf("Enter value ");
scanf("%d",&x);
for(i=x;i>1;i--)
{
res=res*i;
}
printf("Factorial is %d",res);
}
Figure 1
Figure 2