Posted by : ANIMESH SHAW Saturday, 8 October 2011

#include<stdio.h>

int fact(int n)
{
int factor=1;
if(n==1)
{
return 1;
}
else
{
factor=n*fact(n-1);
return factor;
}
}

main()
{
int n;
printf(“Enter a number\n”);
scanf(“%d”,&n);
printf(“Factorial of %d = %d\n”,n,fact(n));
}



OUTPUT:



Enter a number

7

Factorial of 7 = 5040

Popular Post

Blog Archive

Total Pageviews

Sign In

Follow by Email

Powered by Blogger.

Like Us on Facebook

Search This Blog

Loading...

Indian Coder

- Copyright © Programming Mania -Metrominimalist- Powered by Blogger - Designed by Johanes Djogan -