Program Using Recursive Function

#include<iostream.h>
#include<conio.h>
int fact(int x);
void main()
{
clrscr();
int a,b;
cout<<"enter the number whose factorial you want to get :- ";
cin>>a;
b=fact(a);
cout<<"factorial of "<<a<<" is :- "<<b;
getch();
}
int fact(int x)
{
if (x==1)
return (1);
else
return(x*fact(x-1));
}

Comments

Popular Posts