Site icon T4Tutorials.com

Write a C++ Program To Find The Factorial Of A Number By Using The Recursion.

Write a C++ Program To Find The Factorial Of A Number By Using The Recursion.

#include <iostream>
#include <conio.h>
using namespace std;
int main ( )
{
      int n,  T4Tutorials_Factorial(int);
      cout<<"Please Enter the value of N: “<<endl;
      cin>>n;
      cout<<" Factorial of the Number "<<n<<" is "<<T4Tutorials_Factorial(n);
      getch ( );
}
     int T4Tutorials_Factorial(int n)
      {
               int m;
             if(n==1)
              {
                 return (n);
               }
             else
              {
                  m = n * T4Tutorials_Factorial(n-1);

                  return (m);

              }
        }

Output

Please Enter the value of N: 4

Factorial of the Number 4 is 24

More Practice on Factorial problem in C++

  1. Factorial Program in C++
  2. factorial using single inheritance
  3. Factorial Program in C++ using Class Objects
  4. factorial using Multiple inheritances
  5. C++ program for factorial using Constructor DestructorFactorial Of A Number By Using The Recursion
  6. Factorial Program with structures and pointers C++
  7. Factorial Program with Nested Structure C++
  8. factorial of a no. by defining the member functions outside the class

Exit mobile version