Answer:
Step-by-step explanation:
The following code is written in Python. It creates the function called sum_of_ends and does exactly as the question asks, it sums the first and last elements of the array and returns it to the user, if the array is empty it will return 0.
def sum_of_ends(num_arr):
if len(num_arr) == 0:
return 0
else:
sum = num_arr[0] + num_arr[-1]
return sum