holbrookcole984 holbrookcole984
  • 03-12-2018
  • Computers and Technology
contestada

Given an array arr, of type int, along with two int variables i and j, write some code that swaps the values of arr[i] and arr[j]. declare any additional variables as necessary.

Respuesta :

tonb
tonb tonb
  • 03-12-2018

You'll need a helper variable for this, so depending on your programming language, the solution becomes:

int helper;

helper = arr[i];

arr[i] = arr[j];

arr[j] = helper;

Answer Link

Otras preguntas

I need help with #45...
The distance Train A travels is represented by d=70t,where d is the distance in kilometers and t is the time in hours.The distance Train B travels at various ti
What is the main role of a hormone? to provide energy to the cells all over the body after release into the circulation to carry information to cells in the bod
By how much should a pair of light rays from a common source differ in distance traveled to produce destructive interference?
Which of the following illustrates an example of a string data type?
William Wordsworth is considered one of the central writers of the Romantic period because his poems
What is 3.47 rounded to the nearest tenth?
the sun's energy heats Earth's surface unevenly, resulting in convection currents in the atmosphere. which of the following result from these convection curren
what causes global wind patterns ?
which of the following statements regarding processing is true?