Can anyone explain how this recursion code works exactly and what happens in the programs stack or in memory step by step? : <p>Here is my code:</p>

<pre><code>#include &lt;stdio.h&gt;

void fun(int n)
{
    if(n &gt; 0)
    {
        fun(n-1);
        printf("%d ", n);
        fun(n-1);
    }
}

int main()
{
    fun(4);
    return 0;
}
</code></pre>

<p>and the output of this code is <code>1 2 1 3 1 2 1 4 1 2 1 3 1 2 1</code>.
But I can't understand what happens exactly between to recursive calls, When the print statement will be executed and what is the value of <code>n</code> at every call.
I'm beginner in coding please explain step by step.  </p>
