I think my code is correct but getting segmentation fault..can you tell my mistake in comments in program

question: maximum subarray sum