int sum(int arr[]) {
int result = 0;
for (int i=arr.length; --i>=0;)
result += arr[i];
return result;
}
Looks pretty familiar, except for arr.length