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

Any facts on string art? I can't find any!
Mary is making a pinata that has a ball-like shape. The pinata has a surface area of 40 feet. Use the formula for the surface area of a sphere: (S=4πr^2) to fin
Which of the following changes will decrease the rate of collisions between gaseous molecules oftype A and B in a closed container? A. decrease the volume of t
How was society organized in the Middle Ages?
What is the value of x? A right triangle with a short leg measuring 5, a long leg measuring 5, and the hypotenuse as x.A. 10 B. 5C. [tex] 2\sqrt5 [/tex]D. [tex
a bicycle wheel travels about 82 inches in 1 full rotation. What is the diameter of the wheel, to the nearest inch? (use 3.14 for pi)
Which statement is true of a placenta? a. The placenta passes oxygen, nutrients, and other useful substances from the fetus to the mother. b. The placenta passe
how do you simplify fractoins
i need a diagram for how a scrap heap magnet works
What is cos P?  Right triangle PQR with a short leg measuring 5, a long leg measuring 12, and the hypotenuse as 13A. 5/12B. 12/13C. 5/13D. 12/5