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

Which two numbers have a difference of 5 and a product of 3.36???
write words to match the expression. 24- ( 6+3)
If you are writing a persuasive essay in favor of banning vending machines in schools, which is a counterargument you might anticipate?
write words to match the expression. 24- ( 6+3)
If you are writing a persuasive essay in favor of banning vending machines in schools, which is a counterargument you might anticipate?
what other areas beside egypt did the new kingdom pharoahs conquer
what other areas beside egypt did the new kingdom pharoahs conquer
Which two numbers have a difference of 5 and a product of 3.36???
Which two numbers have a difference of 5 and a product of 3.36???
which city was located nearest the nile river delta