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

Compare the various effects that alcohol has on the mind and body at two different blood alcohol concentrations.
What Is the Connection Between Sulfuric Acid and Hydrochloric Acid?
determine the most precise name of the quadrilateral ABCD from the information given. for #13 & #14
What cruel action did macbeth order to insure his status
How many different ways can you group a red apple, a green apple, a tomato, and a banana? (For example , I'll place apples in one group, and non-apples in anoth
If x= (a^2)/b, which situation would always double the value of x? (1) Doubling the value of a(2) Halving the value of a(3) Doubling the value of b(4) Halving t
the measure of distance from one point to another is?
Could you tell me what Are Spores?
Which is the correct solution set for 4x^2 +4x -3 = 0? (1) {2,-3}(2) {1/2, -3} (3) {1,2}(4) {1/2, -3/2}
Which sentence does not contain any errors? A. Fortunately, information on they're collars helped us locate the owners of the dogs.