Pages

Friday, 2 December 2011

WRITE A C PROGRAM TO FIND FACTORIAL OF A NUMBER

/*Program to find factorial of a given number using recursion*/
#include<stdio.h>
#include<conio.h>
//recursive function to find factorial
int fact(int n )
{
if(n==0)return 1;
else
return n*fact(n-1);
}
//main function
void main()
{
int n,f;
//accept number
printf("Enter number to find its factorial:");
scanf("%d",&n);
f=fact(n);
printf("Factorial of %d is %d",n,f);
getch();
}

1 comment:

Unknown said...

Sometimes one creates a dynamic impression by saying something, and sometimes one creates as significant an impression by remaining silent. See the link below for more info.

#significant
www.mocsbar.com

Post a Comment

**FRESHER JOBS**