Q:

Why does my recursive function print in descending order and then in ascending order? 

I have a simple recursive c++ program and I am trying to understand exactly how it works.  I understand why the program prints out 3 2 1, but then I don't understand why it goes the other way and prints 1 2 3.  I used a hand-simulation and walked through the program step-by-step but still don't understand how the 1 2 3 comes about.  I found this article from GeeksForGeeks but am still having difficulty grasping the concept.  Any explanation would be awesome. 
#include <iostream>

using namespace std;

void test(int n)
{
  if (n > 0)
  {
    cout << n << " ";
    test(n - 1);
    cout << n << " ";
  }
}

int main()
{
  test(3);
  return 0;
} 

A:

The order of function calls in your recursion looks something like this:
test(3)
-- cout << 3 << " ";
-- test(2)
-- -- cout << 2 << " ";
-- -- test(1)
-- -- -- cout << 1 << " ";
-- -- -- test(0)
-- -- -- cout << 1 << " ";
-- -- cout << 2 << " ";
-- cout << 3 << " ";

