In the above shown code if we try to find the last element in the array it shows -1 why is that so

same as title…