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

What is the 3rd amendment
Anne Frank kept her diary which was later published as the diary of a young girl for just over
The turning point in Greek history was the _____ A.Persian Wars B.Hellenistic period C.Peloponnesian Wars D.Alexander period
HELP SOMEONE HELP ME PLS HELP! Line segment CD is shown on a coordinate grid: The line segment is reflected about the y-axis to form C'D'. Which statement desc
For some reason I'm just lost
What is the best description of a heterotroph? A) an organism that must "eat" food for energy B) cells that have nuclei C) a single-celled organism
the woman in this drawing is how many heads high?
What goes in the empty boxes?
How to write each fraction or mixed number as a decimal
A satellite in deep space is on a mission to Neptune. It fires its engines to change its velocity toward Neptune at a speed of 200 kilometers per hour. Suddenl