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

If one body is positively charged and another body is negatively charged, free electrons tend to A. move from the negatively charged body to the positively ch
What is the formula of sulfurous acid? H2S HSO4 H2SO4 H2SO3
When European countries set up empires of colonies in Africa and Asia, they were practicing?
Who wrote Neighbour Rosicky?
• Machine s is cleaned every 12 weeks. •Machine that is cleaned every 8 weeks. What is the fewest number of weeks that will pass before both machines are cleane
What are chemical reactions?
which is greater 1/2 or 1/6
When might a dissenter show resilience?
help plz! ASAP Plz help with the prob below
Which of the following is NOT a lifestyle risk factor for cardiovascular disease? a. physical activity b. obesity c. diabetes d. tobacco use