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 garden in the shape of a square has an area of 150 square feet. how much fencing is needed to fence it in? (hint: the length of each side of a square is equal
It takes 40 units of maple sap to produce one unit of maple syrup. Jane and her family are bottling maple syrup in 20 oz. bottles. She notices that they add abo
Which type of appraisal involves judgment about the degree of potential harm or threat to well-being that a stressor might entail?
Simplify each radical expression 31. 5√6-3√6 32. √2(√8+√6) 33. (3√2-2√5)(4√2+2√5)
How far is (-3,-4) from (4,-4)
What is the term for a type of reaction in which two substances react to produce a single compound?
I need help with that please
What did Puritan leaders probably force all colonists to do? A. Persecute non-Puritans B. Attend church services C. Convert to the Church of England D. Partici
a great way to cool food is to constantly do what to the food?
Why was marbury v Madison considered a landmark Supreme Court case