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 town doubles its size every 38 years. If the population is currently 44,500, what will the population be in 152 years?
Help me part a and B
The monthly incomes from a random sample of workers in a factory are given below in dollars. Assume the population has a normal distribution and has a standard
A squad needs to cross a narrow footbridge across a windy, mountain chasm to execute a critical mission. The squad leader is concerned about the hazards and ass
The change of state of evaporation
Find an equation for the line that passes through the points (-3,-2) and (1,4)
2. A cup of coffee costs $2. If the total cost IS $18, how many cups of coffee were purchased? a. Write an equation: b. What is the constant of proportionality?
How should an animal’s intelligence factor into the way humans treat them?
What stretches north from Mozambique into syria
Al examinar una mezcla de reactivos utilizando papel tornasol rojo, se obtiene una coloración azul indicativa de presencia de hidróxidos, el óxido que reaccionó