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

Explain what is the same about two fractions that are like fractions
having troubles with inequalities.. 3.8x + 14.5 < 32
having troubles with inequalities.. 3.8x + 14.5 < 32
Explain what is the same about two fractions that are like fractions
what is the sum of 7/10 and 6/100
which trinomial is equivalent to (3x-1)(x+4)
what is the sum of 7/10 and 6/100
what is the sum of 7/10 and 6/100
having troubles with inequalities.. 3.8x + 14.5 < 32
Explain what is the same about two fractions that are like fractions