#include<stdio.h>//header file
#include<conio.h>//header file
int fact(int);
void main() //starting of the main() function
{
int a,p; //declaration of the variables
clrscr();
printf("program that calculates factorial of (+)ve no. using recursion");
printf("\n\n\n\t\t------------INPUT-------------");
printf("\n\nenter the integer whose factorial is to be calculated");
scanf("%d",&a);//taking input from the user
p=fact(a);
printf("\n\n\n\t\t------------OUTPUT------------");
printf("\n\nthe required factorial is given by:%d",p);//printing output
getch();
}
int fact(int k)
{
if(k>1)
{
k=k*fact(k-1);
}
else
return(k);
}