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

How far is (-3,-4) from (4,-4)
A company bought a total of 4 1/2 feet of cable to connect 3 computers to the wall outlet. Each computer needs the same amount of cable. How many feet of cable
Demand is a powerful force in a free market. In three to four sentences, explain some of the factors that cause changes in demand and why it is important for co
find an equation of a line parallel to y=3x+2 and passes through the point (1,3). Write answer form y=mx+b
The commodities gold and salt were important to many region of west africa because they
Andrea’s work to find the equation of a trend line through the points (48, 61) and (72, 195) is shown below
Marcela estimates the distance between the library and town hall is 735 ft. The actual distance is 612 ft. What is the percent error in Marcela's estimate? Roun
Would you expect the other pairs of students in your class to have an offspring completely similar to yours? Explain.
"survival of the fittest" may be a misleading phrase to describe the process of evolution by natural selection because:
The average age of residents in a large residential retirement community is 69 years with standard deviation 5.8 years. a simple random sample of 100 residents