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

How many moles of Co2 are produced when 0.2 moles of sodium carbonate reacts with excess HCl
What is the role of bacteria in lichens?
Xavier has $23.50 in his savings account. He deposits $35 every week. His mother also deposits $20 into the account every time Xavier washes the car. His saving
An ore contains fe3o4 and no other iron. the iron in a 36.6-gram sample of the ore is all converted by a series of chemical reactions to fe2o3. the mass of fe2o
Which piece of writing is the best example of literary nonfiction? A. A straightforward, factual biography of Abraham Lincoln B. A mockery of a popular TV show,
Ricky made 86 phone calls in 3 months. In the first month she made 21 calls, and in the second month she made 19 calls. How many calls did she make in the third
Simplify: (64x^5y^9z^8)^3/7
In a few sentences, list three functions that the hindbrain is responsible for.
The patient is awake many times during brain surgery. in an operation to remove a brain tumor, dr. judson accidentally poked a certain area of the cerebrum, whe
Reduce the following fraction: -36x^4y^4z^5/-12x^6y^3z A. -3x^2yz^4 B. 3yz^4/1x^2 C. -9yz^5/-3x^2 D. 36yz^5/12x^2