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

50 POINTSSSSFrom a point at the ground level infront of a tower, the angle of elevations of the top and bottom of flagstaff 6 m high situated at the top of a to
Pls help me it’s about math ?
How did U.S. involvement in the Korean War affect the balance of power between the legislative and executive branches of our government?
The rule for a 90⁰ counterclockwise rotation about the origin is: a) (x, y) → (-y, x) b) (x, y) → (y, -x) c) (x, y) → (-x, -y) d) (x, y) → (x, -y)
HELP ME PLEASE!!!! 50 POINTS!!!!What type of inheritance pattern does the pedigree illustrate?​
Object's mass = 2 kg, f1 = 5 newton, f2 = 3 newton. the magnitude and direction of the acceleration is?
Read the poem. Chores Spritz, clean, scrub. Wipe, swipe, rub Pane after pane. Windows are a waste! Unless… I share the clouds with a flock. A soaring clone
Why Not all sources of information are useful to quench curiosity?​
I will give brainliest for first correct answer Solve this system of equations: 2x+4y=10 4x+8y = 20
What is the empirical formula for a compound that undergoes combustion analysis and produces 12.32g of CO₂ and 6.71g of H₂O?