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

In each reaction box, place the best reagent and conditions from the list below.
What is the value of the expression shown below? 7+(10-4) 2 (2 is second power) /4* (1/2) 3 (3 is second power).
Was the United States justified in going to war against Mexico in 1846? Please review my answer. Answer: I would say that Yes, the United States was and is jus
Some African American leaders responded to segregation by A) tearing up railroad ties and burning houses B) educating themselves and writing pamphlets C) going
it can be more than one answer
The instructions for making new copies of a virus are (1 point) part of a virus's capsid. coded in proteins on the surface membrane. coded in either RNA or DN
Which observation illustrates the law of conservation of mass? The C:O mass ratio of a particular compound is the same, regardless of the size or source of the
3.050904 in standard form
Two quantities are related, as shown in the table below: x y 2 3 4 4 6 5 8 6 Which equation best represents the relationship? (4 points) y = x + 2 y = x + 1 y
Many schools have a dietician on staff. True of False