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

In a video game, you move a spaceship 1 unit left and 4 units up. Then you move the spaceship 2 units left. Rewrite the composition as a single transformation b
What is the theme of Donovan Livingston's “Lift Off”? You must use ACES format in your response.
A machine distributor sells two models, basic and deluxe. The following information relates to its master budget.
Fill in the blank with the correct HOBBIES vocabulary word: Me gusta el agua, voy a ___________.
Which statement is TRUE of an archaeological survey? A. Small test pits can be conducted in an undisturbed part of the surveyed area to find buried artifacts t
Binder Corporation agreed to build a warehouse for a client at an agreed contract price of $4,000,000. Expected (and actual) costs for the warehouse follow: 201
3х + 4y = - 23 х = 3y+1 Solve systems of equations!
Observations of Mier y Teran in 1830 ●Anglo settlers not following Mexican laws ●Anglo settlers buying products from U.S. instead of Mexico ●Anglo settlers outn
Vegetables help us have: A restful night's sleep Healthy skin and eyes Indigestion Properly working sweat glands
What happened to the European colonies in Asia and Africa following World War 2?​