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

You want to put $2,000 in a simple interest account. It has a 2.5% annual interest rate. How long will it take you to earn $500 in interest? A-1
Which word in this sentence is a participle? The salesperson carefully folded the crumpled garments. a. crumpled b. carefully c. folded d. garments
Describe the main difference between metaphase I and metaphase II.
Why have the Atlantic Provinces developed differently than the Northwest territories? a. The Atlantic Provinces have a more temperate climate and are suitable f
why is the middle kingdom the golden age
why is scout worried about him?
In angela's ashes what sort of treatment does frank receive for his typhoid fever
rappelle-toi : quels sont les verbes conjugues avec avoir
Eating habits are closely related to such health problems as complexion, overweight, and high cholesterol problems? True or False
how to write 19.238 in word form