Tag Archives: factorial c code

Write a program to display factorial of a number


#include<stdio.h>
void main()
{

int n,i;
long int fact;

printf(“Enter the no whose factorial is requiredn”);
scanf(“%d”,&n);
fact=1;
i=1;
if(n>=2)
while(i<=n)
{
fact=fact*i;
i++;
}
printf(“Factorial of the %d is %ldn”,n,fact);
}

Advertisements