What does the code do

Report a typo

What is the result of the pseudocode function below?

function func(array):                  
    if len(array) == 0 then:     
        return -1            

    result = 0                  
    
    for i in [1, len(array)]:  
        if (array[i] > 0) then:
            result = result + array[i]
    
    return result

The input numbers are 1 -2 3 -4 5.

NB: Recall that usually in pseudocode, the indexing starts from 1.

Enter a number
___

Create a free account to access the full topic