Just a minor update, that is for user interaction, we need to ask the user about the size of array. Then it should get the elements in array. Because for now it just ask for entering elements in an array and gives the result after 5, let's make it dynamic.
@ShehrozIrfan I will make changes.