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++
- Factorial Program in C++
- factorial using single inheritance
- Factorial Program in C++ using Class Objects
- factorial using Multiple inheritances
-
C++ program for factorial using Constructor DestructorFactorial Of A Number By Using The Recursion - Factorial Program with structures and pointers C++
- Factorial Program with Nested Structure C++
- factorial of a no. by defining the member functions outside the class
