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

DO all organisms share the same genetic code
how can you perform math and physics and what you should do to catch up
Explain the process used in forming metals. Name one occupation in history that used forming in metalworking.
A tennis player throws a ball vertically upwards at 4.90 m/s. How long, in seconds, does the ball take to return to his hand (assuming it has not moved since re
Which is the best example of Newton's first law of motion
Suppose that the students also sold $4500 worth of pens and pencils, which earned a 42% profit the profit the school earned on pens and pencils. Calculate
Subtract: a. 14 – 7 – 5 b. (35 – 20) – 3 c. 45 – (23 – 14) d. 56 – 32 – 5
1. Which of the two music styles did you most enjoy? What drew you to that style over the other? 2. What are some ways that modern technology is used in music
When did people begin to notice that coastlines of continents fit together like puzzle pieces? A. when satellites began taking pictures of Earth from space B.
the product of a number and 3.17 is equal to 6.51 more than the number. find the number