#include< stdio.h >
#include< conio.h >
void main()
{
int num,facto;
int fact (int num);
clrscr();
printf("Enter a number:");
scanf("%d",&num);
facto=fact(num);
printf("Factorial=%d",facto);
getch();
}
int fact (int num)
{
int i,a=1;
for(i=1;i<=num;i++)
{
a=a*i;
}
return a;
}
OUTPUT :
Enter a number:3
Factorial=6
No comments :
Post a Comment