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

Why did the Spanish government establish the encomienda system in the Spanish colonies? to grant land to American Indians to divide land equally to defend the A
The colonists were angry because the British kept taxing them. True or False?
find the equation of the line that is perpendicular to y = -2/3x and contains the point (4, -8)
john was looking at his streaming music stats. the ratio of songs he liked to disliked was 5:2. if he listened to 91 songs total how many did he like
Write a quadratic equation in standard form that has two solutions, -10 and 3
-5.73q = 97.41 q= please help me???
Plz help me get the answer
The correlation coefficient r between the age of a homeowner, x, and the number of years remaining on the homeowner's mortgage, y, is 0.485. What percent of the
What is the approximate solution to the equation 2^t =38
In what group are the most stable inert elements located