Factorial
#include<stdio.h>
void fac(long long int a)
{
long long int f=1;
int i;
if(a==0)
{
printf("Factorial is 1\n\n");
}
else
{
for(i=1; i<=a; i++)
{
f=f*i;
}
printf("Factorial is %lld\n\n",f);
}
}
int main()
{
long long int n;
printf("\nEnter a Number : ");
while(scanf("%lld",&n)==1)
{
fac(n);
printf("\nEnter a Number : ");
}
return 0;
}
No comments:
Post a Comment