Jun 132012

What will the below function return when it is called for n=1 as fun(1). Treat is as the first call to fun function, so i is not initialized earlier.

    int fun(int n)
        static int i = 1;

        if (n >= 5)
            return n;

        n += i;
        return fun(n);

Continue reading »