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

Please help answer ASAP
Solve for t. −22t>66 Enter your answer, as an inequality, in the box.
Plz help need badly What is the value of this expression? (3/7)^0 A) 0 B) 3/7 C) 1 D) 30/7
What was significant about the Virginia and Kentucky resolutions?
Please help!!!! Culinary Arts Math
Which function has a domain of all real numbers except x=pi/2+_npi? A. Y=cos x B. Y=cot x C. Y= 1/sinx D. Y=sec x
Nutrition n brain helpppp What substances in our diet are used to make up the myelin of our neurons? Is omega-3 so good for mental health because it participat
Consider this topic for a survey: How far do students at Alpha Elementary jump? Which of the following would lead to a biased sample? Randomly choose severa
What are next four fractions after 3/4,1,?
Which of the following is NOT a living organism? A. a muscle cell B. an amoeba C. a rosebush D. an earthworm What characteristic do all living things share