Got wrong output if maximum sub array computed over 0th index

If i give input of array as 1 2 3 4 then i am getting max subarray sum as 9 and subarray as 2, 3, 4.
I think it should be 10 for subarray 1, 2, 3, 4.

Here is my code link:

currentsum=cumsum[j]-cumsum[i-1]; // for i = 0 index become -1 for i-1. I think this is creating a problem.

@aditikandhway
you have to do this,
because for i = 0, you will access cumsum[i-1] which is cumsum[-1]
to avoid this you can handle that case manually.
if(i!=0)
currentsum=cumsum[j]-cumsum[i-1];
else
currentsum = cumsum[j];