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

The influence of Mohandas Gandhi be seen most clearly in King’s rhetoric in his
choose the equation below that represents the line passing through the point (-3,-1) with a slope of 4. A) y = 4x - 11 B) y = 4x + 11 C) y = 4x + 7 D) y = 4x -
how to eliminate negative self-talk
which of the following sources of energy is not renewable? wind energy wave energy solar energy fossil fuels
What is the reciprocal of 1/5
The specific gravity of basalt is about
may someone help me out with this
A mural inspired by a photograph measures 108 inches by 108 inches the scale factor is 12 what are the dimensions of the photograph
The innermost part of a grain that is rich in protein, oils, vitamins, and minerals is known as the a. husk. b. endosperm. c. germ. d. bran.
Please select the word from the list that best fits the definition Scientists who possess this attitude are eager to find answers to different questions they ha