Maximum subaray sum

sir what is my mistake and which loop are you talking about

I have corrected your code. Check now.