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

Somebody help Janele! XD quartz gym....interesting, janele
Did the Industrial Revolution have a positive or negative effect on peoples quality of life?
Why do the days get shorter as winter approaches in the Northern hemisphere?
what is the theme of the song "red" by taylor swift?
The woman in the house across the street what happened to her daughter.
Write the equation in slope-intercept form that has a x-intercept of 30 and a y-intercept of 15
McKayla can type 342 words in 4 minutes. Find the unit rate in words per minute.
Which of the following is a disadvantage of conducting a laboratory experiment? A. Cause-and-effect relationships are easier to determine in laboratory experime
Zach gave 2/8 of his coin collection to his sister and 4/8 to his friend. What fraction of the collection did he give away? Show working too (HE STARTED WITH 8
deshawn is following his grandmother biscuit recipe he uses 3 cups of flour for every 2 cups of buttermilk here comes the question if Deshawn uses 6 cups of flo