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 does the phrase foe to ambition.
Write in function form X+y=6..?
in what way is a gene pool representative of a population
mike constructed a closed box that measures 2.5 feet long by 3 feet wide by 1.5 feet high. what is the total area of the material mike needs to construct the bo
The net force acting on a 50 kg crate is 0 N. What is the crate's acceleration
The skeletal system does all of the following EXCEPT (A) support. (B) transport. (C) protect. (D) digest. (E) store.
Randal answers 96 out of 120 questions correctly on a science exam. What percent of the questions did Randal answer correctly
A car salesperson earns 1.5% commission on every car sold. The salesperson sell a car for $22,500. What is the commission?
three things scientists learned about earth in beginning of 1800s
Randal answers 96 out of 120 questions correctly on a science exam. What percent of the questions did Randal answer correctly