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

Round 75,499 to the nearest thousand.
If the length of the pool is 14 1/2 feet , the width is 6 1/2 feet, and the depth is 6 1/2 feet, what is the volume of the pool?
The length of the base of a rectangle prism is 3 feet and its width is 2 feet. The length of the diagonal of the prism is 6 feet. What is the height of the pris
I really do not know how to do this, I already asked my teacher to explain it to me, but I still don’t understand. Can someone please help me I would be very gr
definition of heat in own words
How can you tell were an ocean begins and ends?
sometimes a linear equation is not written in slope intercept form. how do you convert an equation such as y + 2= x into slope intercept form​
You are a doctor treating a patient who has recently experienced paralysis in his lower body. He asks you to give him more information about the use of adult st
PLEASE HELP ME FACTORISE THIS ASAP! TYSM ;)–3x+2y=94x+5y=–11​
Shane has 4/5 of a bar of chocolate. He shares it equally between two people. What fraction of the bar do they each get?​