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

George washington's farewell address gave a strong message about foreign policy what was it
This figure shows the procedure for constructing a
What are some similarities and some differences between turnpikes in the 1800's and turnpikes today?
A self-_________ plant contains both male and female reproductive structures?
The global economic crisis following World War I was caused by a. widespread unemployment. b. unpaid WWI debts. c. the Great Depression. d. overspeculation
Solve the system of equations and choose the correct answer from the list of options. d + e = 1 −d + e = −5 Label the ordered pair as (d, e). (0,0) (3, -2) (
Complete the following calculations. Round off the answers to the correct number of significant figures. 16m × 2.82m × 0.05m
How many ounces in a gallon?
One of the major benefits that resulted from the The Alar "scandal" in 1989 was
What is feminism? A. The theory that women are superior to men B. The study of the female mind C. The theory that women are inferior to men D. The theory