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 moon is not visible during which phase A.waxing crescent B. New Moon C. Full Moon D. First Quarter
What is the answer with this math
If a typical tablet contains 2.0 g of sodium hydrogen carbonate how many miles of CO2 should one tablet yeild?
The military nobility and the ruling class of warriors who pledged allegiance to the shogun were called A. the bushido. B. the kamikazes. C. the samura
What is the answer??
Which of the following systems of farming is farming whereby farmers remain settled in one place to grow their crops? A. Subsistence Farming B. Commercial Farmi
Echoic sensory memory is used when a lightning bolt flashes across the sky.
What was upton sinclairs main purpose in writing the jungle book
Why did Howe's Philadelphia victory lead to defeat at Saratoga?
What were the benefits and costs of prosperity in the 1950's