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

What are the different types of bone fractures and how are they identified on x-rays?
Hich equation is in slope-intercept form and represents a line with slope 3 through the point (9, –4)?
People infected with stds often do not realize they have an infection because many stds can be __________.
find the solutions of the quadratic equation by completing the square,show your solutionsW^2 +6w-11=0
According to the textbook, we tend to call something like a car or a student "good" when it aligns with most people's preferences. is flashy, unique or expensiv
Construct a food chain with the following organisms-snake,hawk,rats and plants
He _____, written in 1215, established the belief that the monarch's rule was not absolute and provided the basis for the later development of parliament.
Fermium-253 has a half life of three days. A sample contains 400 g. How long will it take for the sample to decay to 100 g?
which graph does not represent y as a function of x
Tiffany used her debit card to buy lunch for $9.72 on Wednesday. On Thursday, she deposited $9.72 back into her account. What is the overall increase or decreas