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

what is the idea of the nightmare art by Henri fuseli gave me 1-3 sentences answer please
A characteristic that the two processes have in common is that each process?1) Uses ATP 2) Requires enzymes 3) Uses oxygen 4) Moves molecules
ich expressions are equivalent? Select Equivalent or Not equivalent for each pair of expressions. Equivalent Not equivalent 3(a+b) and 3a+b 4(x+2y) and 8y+4
A sample of co2 solid and co2 gas differ in their
Assessment items Is this statement true or false? The difference between the Declaration of Independence and the Constitution is the Declaration states goals
Grant was considered a successful leader because he ignored his past battles. he was promoted quickly. he wanted to learn from his mistakes. he knew how to run
What is the value of the expression 3,972 divided by 12
My answer is wrong I need the correct answer and show your work by step by step
At what angle should you hold utensils while feeding patients at mealtime
Consider the element carbon. How many electrons can be found in a carbon atom? How many are valence electrons? A) 6; 2 B) 6; 4 C) 12; 4 D) 12; 6