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

Write a story, please
9. All quadrilaterals are parallelogram. A True B. False C. Maybe D. Sometimes cial kind of na lelogram because​
evaluate the expression 2b^3+5 (BTW I did the first part it's 3 but I need the second part)​
the pH of an acidic solution is 2.47. what is the [H+]
Briefly explain ONE argument that supports the view that the Spanish-American War was caused by imperialist motives.
how do you do one step equations?
Why is Heracles (Hercules) the favorite son of Zeus?
when russia invades ukraine what will happen to us stock market
Order their calculations from greatest to least Leon-------Mika-------Jason------Ashley√17 - 2-----1 + π/2 -----12/5---------2.5
Given similar terms, solve for the missing variables (x)