Maximum Subarray Problem - Recursive O(n log n) algorithm
Your program fails when all of the members of an array are negative, it simply returns 0 instead of the maximum negative number.  



Recursion here is slowing you down.  Using Kadane's algorithm, we can make the time complexity linear, or O(n) .

#include&lt;stdio.h&gt;

#define max(a, b) (((a) &gt; (b)) ? (a) : (b))

int maxSubArraySum(int array[], int size)
{
    int maxSoFar = array[0];
    int currentMax = array[0];

    for (int i = 1; i &lt; size; i++)
    {
        currentMax = max(array[i], currentMax + array[i]);
        maxSoFar = max(maxSoFar, currentMax);
    }
    return maxSoFar;
}

int main()
{
    int array[] =  {-2, -3, 4, -1, -2, 1, 5, -3};
    int len = sizeof(array) / sizeof(array[0]);
    int maxSum = maxSubArraySum(array, len);
    printf("Maximum contiguous sum is %d\n", maxSum);
    return 0;
}