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

Communism and socialism are usually found in what type of economic system?
What property of DNA does bacterial transformation illustrate?
The price of a digital camera sold in stores is $129. It is sold on eBay for $65. What is the percent decrease from the store's price to the online price
75% of what number is 105
a punch recipe that serves 24 people calls for 4 liters of lemon-lime soda, 2 pints of sherbet,and 6 cups of ice. How much of each ingredient would you need to
why does phaethon go to apollos palace
_______ rock can be changed directly into _______ rock with the application of heat and pressure.
How high must a cranberry bounce before it is harvested?
American Indians in the St. Lawrence River region began to fight among themselves in the 1600s because of
Gretchen is using an overhead projector to enlarge a drawing so she can make a poster. The original drawing measures 60 mm wide by 80 mm high. She moves the pro