#include
#include
int rec(int a);
main()
{
int x,fact;
clrscr();
printf("\n\nENTER THE NO.=");
scanf("%d",&x);
fact=rec(x);
printf("\n\nFACTORIAL OF %d=%d",x,fact);
getch();
}
int rec(int a)
{
int b;
if(a==1)
return(1);
else
b=a*rec(a-1);
return(b);
}
/**********************************************************************
OUTPUT
**********************************************************************
ENTER THE NO.=5
FACTORIAL OF 5=120
*/
No comments:
Post a Comment