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

The gravitational attraction between two masses varies inversely as the square of the distance between them. If the attraction force between them is 75 lbs. whe
emma borrowed 81.60 from her sister .she determines that she can pay her back in six months worth of allowance . what effect will be Emma's repayment have on he
Which of the following is a way to increase economic development ? A. Raising taxes B. Investing in education C. Limiting trade D. Lowering wages ??
A major effect of geography on japan is that the?
The rule of law, established under Hammurabi, was the idea that 1. different laws apply to people of different social ranking 2. all members of society, even th
What is the Figurative language of hugging the jukebox by Naomi Shihab Nye?
date of battle of Yorktown
Summarize the processes that formed the ocean
Which nation joined nato when it was created in 1949
A team of biology students performed an experiment to test the effects of four different solutions on a de-shelled, raw chicken egg. Each raw, unbroken chicken