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

a number minus one is at the most nine, or two times the number is at least twenty-four.
Read the following excerpt. Using the context of the paragraph, select the word that best completes the sentence. The dramatic changes that characterize pubert
Ebonae's fish tank holds 40 gallons. How many quarts does the fish tank hold
how does a walkie talkie transfear to each walkie talkie
why was the D-Day plan so risky?
Which of the following practices is most likely to increase the chances that a personal fitness program will be successful? A. breaking fitness goals into smal
Read the following paragraph, and answer the question. 1The poor are wise, more charitable, kinder, more sensitive than we are. 2In their eyes, prison is a trag
The British ended the opium trade to China in 1836. a. True b. False
Aiden baked 8 dozen muffins. how many total muffins did he bake?
The Magna Carta did not____________. a. limit the king's power c. subject the king to common laws b. establish the English Parliament d. establish rights fo