C Programming - Two for loops to recursion
<p>I was trying to make recursive function that would simulate two for loops. So, function would have to do this:</p>

<pre><code>int recursion(int n, int i, int j)
{
    for(i=0; i&lt;n; i++)
    {
        for(j=i+1; j&lt;n; j++)
        {
            printf("%d %d\n", i, j);
        }
    }
}
</code></pre>

<p>but, i want it to be recursive. I tried something like:</p>

<pre><code>int recursion(int n, int i, int j)
{
    if(i&lt;n)
    {
        if(j&lt;n)
        {
            printf("%d %d\n", i, j);
            recursion(n, i+1, j+1);
        }
        recursion(n, i+1, i+1+1);
    }
}
</code></pre>

<p>I would call recursive one in main like </p>

<pre><code>recursion(10, 0, 1);
</code></pre>

<p>but output is not the same for those two version of function. May anyone tell me where am I mistaking with the recursive one?</p>