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

Brainstorming is only effective when done _______. A. In groups b. By yourself c. In a respectful atmosphere d. In a limited amount of time Please select the be
What is the median of these numbers: 14, 20, 24, 16, 20, and 18
Find all real zeros of the function y=-5x-7
Which capacity is most appropriate for a pitcher of lemonade 3 litters or 30 milliliters
Levitown was an important part of what post-world war two issue A/ suburban sprawl B/ nuclear pollution C/ Civil rights movement D/ Anti-Vietnam war protest
The product of 17 and 1.27
Name three factors that can influence your food choices
What was similar between Northerners and Southerners?
He model below can be used to find the quotient of one over two divided by one over six. What is the quotient?
What is the first step in solving the equation 2/3 x+1/2 x+2=5