Programming Code Center(PCC)
[CPP]

(PCC)::[How-to-write-CPP-program-to-Calculate-Factorial-of-a-Number-Using-Recursion]::[cpp]

File Name : Factorial_of_Number_Using_Recursion.cpp

//Example: Calculate Factorial Using Recursion
#include<iostream>
using namespace std;

int factorial(int n);

int main()
{
    int n;

    cout << "Enter a positive integer: ";
    cin >> n;

    cout << "Factorial of " << n << " = " << factorial(n);

    return 0;
}

int factorial(int n)
{
    if(n > 1)
        return n * factorial(n - 1);
    else
        return 1;
}

Output :

Factorial_of_Number_Using_Recursion.jpg