Answer:
Following are the program in Python Programming Language.
#define function
def mssl(l):
maxlen = x = 0
#initialize two variable
for i in l:
#set for loop
x = max(x + i, 0)
#check the max value of sum
maxlen = max(maxlen, x)
return maxlen #return the result
list01=[]
#list type variable
while True:
#set while loop
x=int(input("Enter the value or 0 to stop: "))
#get input from the user
if(x==0):
#set if statement
break
#break the loop
else:
list01.append(x)
#append the value of x in listo1
print(mssl(list01)) #call the function
Output:
Enter the value or 0 to stop: -2
Enter the value or 0 to stop: -3
Enter the value or 0 to stop: -5
Enter the value or 0 to stop: 0
0
Explanation:
Here, we define the function "mssl()" and pass an argument to its parameter are the variable "l".
Then, inside the function, we initialize two integer type variable "maxlen" or "x" to 0.
Then, set the for loop and then return the value of the variable "maxlen".
Then, we initialize an empty list data type variable in which we pass the values.
Then, we set the while loop inside it we get the input the user in the variable "x" and then we set the if-else statement.
Finally, we call the function "mssl()" and pass the variable "list01" as an argument.