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

When authors make points in their writing, what do they use to support the points? A. Reasons and evidence B. Antonyms and synonyms C. Cause and effect D. Spel
A hockey puck of mass 150 g is sliding south along the ice and slows at a rate of 1.2m/s2. What is the net force acting on the puck?
Find the mean of the data. 8,14,22,7,2,11,25,7,5,9
why did mammals evolved so quickly after the extinction of the dinosaurs
How does the narrator change while living in New Jersey? O A. He becomes born again. O B. He begins to hate his father. C. He develops a deep resentment for seg
A board is 8 feet 10 inches long. How long is it in inches?
Which student solved the equation 107 d = 1,733.4 correctly? Gianna's work: 107 d = 1,733.4. 1,733.4 times 107 = 185,473.8. Teddy's work: 107 d = 1,733.4. 1,733
Arrange the following acids from strongest to weakest: HF, HBr, HCl, HI
which of the following is NOT a major part weather? a. pressure b. humitidy c. wind d. fronts
ruiz company provides the following budgeted sales for the next four months. the company wants to end each month with ending finished goods inventory equal to 3