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

According to Islamic belief Allah ordained that Muhammad was a subordinate God. the teachings of Jesus and Moses are incorrect and immoral. Muhammad created the
Suppose the plates beneath Earth's surface stopped moving. What do you think would happen? Explain your answer.
Barbara's goal is to practice piano 20 minutes for every 5 minutes of lessons she takes.if she takes a 20 minute piano lesson this week,how many minutes should
what does y =mx +b mean and how do you use it to solve problems? whats the different between y=mx+b and y=mx + c
Lysosomes can be compared to the recycling and garbage centers of a city. How can this comparison be justified? A; They break down their own membranes and diges
Unscramble the word bssmyale
In a foreign country, half of 5 = 3. Based on that same proportion, what's one-third of 10?
Earthquakes happen when _____. a. magma fills the chamber in a mountain b. seismic waves are transferred from the ocean floor to ocean water c. tectonic plates
According to Islamic belief Allah ordained that Muhammad was a subordinate God. the teachings of Jesus and Moses are incorrect and immoral. Muhammad created the
which dispute with Britain was settled in 1846