Saturday, 26 September 2015

Write a C program to find factorial of a given integer k

/* Write a C program to find factorial of a given integer k*/

#include<conio.h>
#include<stdio.h>
fact(int);
void main()
{
int n,factorial;
clrscr();
printf("Enter the number");
scanf("%d",&n);
factorial= fact(n);
printf("Factorial of %d is %d",n,factorial);
getch();
}
fact(int a)
{
int fac=1;
if(a==1)
return(1);
else
{
fac=a*fact(a-1);
return(fac);
}

}

No comments:

Post a Comment