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

Which of the following sentences is written in the passive voice? A. My friend searched high and low for the perfect birthday gift for his mother. B. My friend
Why is the small intestine up to 26 feet long?
A cab ride f I'm your home to the airport cost $23.47. If you want to tip the cab driver close to 10 percent of the fare, how much shout you tip
Which sentence should be revised to include commas to set off a nonrestrictive element? The car in my driveway belongs to my oldest sister. The game that my mom
How was Plato related to Aristotle
A. A band leaves a free T-Shirt under every 6th seat at a concert. They leave a free backstage pass under every 4th Street. Which of these seat numbers get a
Do you hear sounds around you as one frequency at a time or as many frequencies at once? Plz help
CAN ANYONE HELP ME ON THIS PLZ WILL GIVE YOU VOTE? Which sentence best describes how art in Buddhist cave temples along the Silk Road reflects the beliefs of t
A ship sails due west from a harbor for 28 nautical miles. It then sails S68°W for another 17 nautical miles. How far is the ship from the harbor? (Round your a
_____ occurs when sediment gets deposited as the energy of the water decreases.