#include< stdio.h >
#include< conio.h >
void main()
{
int num,factorial;
int fact (int num);
clrscr();
printf("Enter a number:");
scanf("%d",&num);
factorial=fact(num);
printf("Factorial=%d",factorial);
getch();
}
int fact (int num)
{
if(num==1)
return 1;
else
return (num * fact (num-1));
}
OUTPUT :
Enter a number : 5
Factorial=120
No comments :
Post a Comment