code :- https://ide.codingblocks.com/s/133777
I have edited your code as per kadane’s algorithm given in online video lecture of your course.