def reverse(arr,start,end):
          while(start<end):
              arr[start],arr[end] = arr[end],arr[start]
              start+=1
              end-=1
      #get array elements from user
      arr=[]
      n = int(input("Enter length of array:"))
      for i in range(0,n,1):
          arr.append(int(input()))
      reverse(arr,0,n-1)
      #print array elements with space
      print(*arr)
      
      Python language logo

      Reverse an array

      Reverse an array using iterative approach.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.