Ask Question
21 December, 22:17

Write a function swapvectorends () that swaps the first and last elements of its vector parameter. ex: sortvector = {10, 20, 30, 40} becomes {40, 20, 30, 10}. the vector's size may differ from 4.

+2
Answers (1)
  1. 21 December, 22:45
    0
    Depends on language, but the common way to do that is to create temporary variable.

    length = len (sortvector)

    temp = sortvector[0]

    sortvector[0] = sortvector[length-1]

    sortvector[length-1] = temp
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “Write a function swapvectorends () that swaps the first and last elements of its vector parameter. ex: sortvector = {10, 20, 30, 40} ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers