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

Who was involved in the battle of stalingrad
GIVING 30 POINTS PLEASE ANSWER compare and contrast an oratory and an argumentative essay.
Alcohol inhibits the release of ADH from the pituitary gland. This would produce which of the following effects? Water is reabsorbed from urine in the collec
how did the Montgomery bus boycott movement to fight segregation​
Given the net of the rectangular prism, what is its surface area? 96 m2 144 m2 160 m2 180 m2
If a population of 1,000 individuals has 160 rr genotypes, assuming simple dominance by the A allele, what is the frequency of the dominant allele (R) in this p
What was unusual about President Gerald Ford becoming president????
Which of the following pairs are the best examples of homologous structures?(a) bat wing and human hand(b) owl wing and hornet wing(c) porcupine quill and cact
Which statements describe the energy in a food web? Check all that apply. When an organism eats another organism, it loses energy. Producers have the greates
A sphere has a height of 26. Find the surface area, volume and density (D=m/v , where m is 72)​