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

1 inch of rain per year or less in grassland? Is this a lot or a little of rain?
Why is the ability to adjust conclusions when necessary important to critical thinking?
A 12 gallon tank is filled with water at a rate of 1/4in 5 seconds. It will take ____ Minutes and ____ seconds to fill 5/6 of the tank HELP
Where does all of the energy in an ecosystem ultimately come from? Please help
Factor tree for number 119
Factor tree for number 119
Which passage is chronological???
In regards to supply, the law of supply and demand states that as ________________
Rick knows that 1 cup of glue weighs 1/18 pound. He has 2/3 pound of glue. How many cups of glue does he have?
20 is what percent more than 5 ?