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

Who was John Howe ( American revolutionary war) and why did he matter to our history?
PLEASE HELP MEthank you, and 15 points!!Gretchen and Ezia received equal scores on a test made up of multiple choice questions and an essay. Gretchen got 18 mul
Similarities between dance drama and other forms of drama
What is 25% of 6??? Is it 1.5?
Why did a division of labor occur when people started to produce a surplus of food?
How many grams of CO2 are produced by burning 8.32g of C4H10?
fructuse, sucrose, and starch are all examples of ? carbohydrates, lipids,nucleic acids or proteins?
What ratios are equivalent to 9:2
A rectangular park is 150 yards on one side and 125 yards on the other.a. If Debbie walks around the park 2 times, how far does she walk ? b. If Debbie wanted t
Choose the correct function/equation for the following description. A linear function whose graph has y-intercept 6.