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

The gases in the air attracted to earth by gravity form layers called the ____
Morgan found a stone arrowhead. He measured it three times. He measured it as 2 inches to the nearest inch, to the nearest 1/2 inch, and to the nearest 1/4 inch
Fragment in this sentenceWith her heavy dictonary, Donna thumps the top other ancient computer monitor.  Whenever the color tint flickers from normal to sickly
what is the simplest square root of 1345? no decimals please
Newtons third law of motion is also known as the law of ?
Which of the following is formed at a collision zone?Continental rift valleyVolcanic island chainMountain rangeDeep-ocean trench
a soccer team played 160 games and won 65% of them. how many did they win?
Luke made a model that has 1 circular base and 1 curved surface.what solid figure did he make
There is an inverse relationship between x and y. If y is when x is 3, what is x when y is 9? 3 5
what is the simplest square root of 1345? no decimals please