Disqus Shortname

Sunday, August 16, 2015

Program: Factorial of a Number



#include <stdio.h>

long int factorial(int n);

void main()

{

int n;

printf("Enter the number:\n");
scanf("%d", &n);
printf("Factorial of %d is %d", n, factorial(n));
getch();

}

long int factorial(int n)

{

if (n ==0)
{

return (1);

}

else

{

n = n * factorial(n - 1);
return (n);

}
}

/*-via Programming Hub for Android, a top rated Programming App on Google Play

https://play.google.com/store/apps/details?id=com.freeit.java*/


No comments:

Post a Comment