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

A dramatic representation of Jesus's suffering is call a ______ play
Why do you think enslaved people,like Equiano, were not allowed to keep their African names?
Which of the following were advantages of the Federalists in the battle for ratification? (A)a clearly defined program to meet the difficulties of the country (
Jenny spent 35 minutes doing research on the Internet. She finished at 7:10p.m. At which time did Jenny start her research?
what is s squared +2x-35 factor
What is 8/n=n/32?Please I need an answer
Andrei prefers that his mentor focus more on trigonometry instead of algebra. The sentence above uses the verb mood in the imperative. subjunctive. conditional.
The stipulation requiring that accused persons be told they have "the right to remain silent" stems from A. the Monroe Doctrine. B. Marbury v. Arizona. C. the P
Express 0.8211 in exponent form
how did the first two major american political parties differ.