Tuesday, 17 December 2019

Factorial of a Number in C

#include<stdio.h>
#include<conio.h>
void main()
{
int n,i;
long int f=1;
printf("Enter the number");
scanf("%d",&n);
if(n<0)
printf("Factorial Not posible..");
else
{
for(i=1;i<=n;i++)
f=f*i;
    printf("The factorial of %d is %ld",n,f);
    getch();
}
}

No comments:

Post a Comment

Convey your thoughts to authors.