Can someone explain why is the total = 7 in the following code? with static int sum? : <p>Can someone explain why is the total = 7 in the following code? with static int sum?        </p>

<pre><code>    #include &lt;stdio.h&gt;
    int i, j; 
    int madness(int x);
    int main(void) 
    {
    int i, total = 0;
    j = 1;
    for (i = 0; i&lt;3; i++) { total += madness(i); }
    printf("Total = %d\n", total);
    return 0;
    }  

    int madness(int x) 
    {
     static int i;
     static int sum = 0;
     for (i = 0; i&lt;x; i++, j++) { sum += j; }
     return sum;
     }
</code></pre>
