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

Point P is chosen at random in a circle. If a square is inscribed in the circle, what is the probability that P lies outside the circle
What is the degrees in 3 full turns
I need help I struggle with these
What is the function of the 24 councils of government in texas today??
Why is it important to prepare for inclement weather? to help you escape danger to help you remain calm to help you outrun tornados, floods, and hurricanes to
Por que no hay clases el 1 de mayo me ayudan por favor
The graph of a quadratic function touches, but does not cross, the x-axis at x = 4. What function represents this situation?
Which of the following is not represented on the H-R diagram? a. red giants b. white dwarfs c. main sequence stars d. green giants e. all of the above are found
Which trimester is an especially critical period when poor nutrition or drug use can result in birth defects?
What characterizes Prospect of The Future Glory of America as a work from the age of reason?