Get the FREE certificate on C, C++, Java, Python, Perl, PHP, SQL, Linux & Javascript!  

CppBuzz.com
  
Home C C++ Java Python Perl PHP Spring SQL Javascript Linux

You are here : Home » Solved Programs on C++ » C++ Program of Recursion

C++ Program of Recursion

#include<iostream>
using namespace std;

int factorial(int no)
{
int number = 1;    
if(no == 1)
return 1;

number =  no * factorial(no -1);
return number;


}
int main()
{
int no;

cout<<"\n Enter any number : ";
cin>>no;

cout<<"\n Factorial is : "<< factorial(no);

return 0;
}