For what it’s worth, the function is looping through the given array [9,8,6,2]
and adding the numbers together. It’s essentially a sum of the values of the given array.
The var s
is initially zero (0) (int s = 0
). It loops through each value in the array and adds it to itself (s = s + arr[i]
). As the loop continues, the value of s
continues to grow.
Therefore, the returned value of the function would be 25:
s = 9 + 8 + 6 + 2