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

A rectangular courtyard is 12 feet long and 8 feet wide. A tile is 2 feet long and 2 feet wide. How many tiles are needed to cover the courtyard?
What were copernicus’s ideas about the order of the universe deemed to be dangerous to church thinking? (5 points) A.The church was invested in the idea that th
What side of the American civil war would you choose to fight for and why
How is organizing history by theme different from organizing history by region? A. A historian who organizes history by theme focuses on a specific individ
which group of islands is called the land of fire and is located at the southern tip of South America
Find the gcf of 12,30,72
The trapezoid is composed of a rectangle and two triangles. What is the area of the rectangle? What is the total area of the triangles? What is the area of the
329 people went to an amusement park. $906 was made that day. $1.5 per kid. $4 per adult. how many kids and adults went?
How do diseases caused by bacteria and diseases caused by viruses react to antibiotics?
Moral principles is what ? A. Appreciation B. Tariff C. Fiscal D. Ethics