Check out example codes for "recursive in c++". It will help you in understanding the concepts better.

Code Example 1

// A C++ program to demonstrate working of 
// recursion 
#include<bits/stdc++.h> 
using namespace std; 
  
void printFun(int test) 
{ 
    if (test < 1) 
        return; 
    else
    { 
        cout << test << " "; 
        printFun(test-1);    // statement 2 
        cout << test << " "; 
        return; 
    } 
} 
  
int main() 
{ 
    int test = 3; 
    printFun(test); 
}

Learn ReactJs, React Native from akashmittal.com