PROGRAM TO FIND FACTORIAL OF A NUMBER USING FUNCTION RECRUSION

#include<iostream.h>
#include<conio.h> 

long int Factorial(int); 

void main() 
{
int n;
long int f;
clrscr();
cout<<"=====================================================\n";
cout<<"PROGRAM TO FIND FACTORIAL OF A NUMBER USING RECURSION\n";
cout<<"=====================================================\n\n";
cout<<"\tEnter any number : ";
cin>>n;
f=Factorial(n);
cout<<"\n\tFactorial of "<<n<<" is "<<f<<endl<<endl ;
cout<<"=====================================================\n";
getch();
}

long int Factorial(int x)
{
long int a;
if(x==1)
return(1);
else
a=x*Factorial(x-1);
return(a);
}




No comments

Post your comments

Powered by Blogger.