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

Read the first two lines of "Because I Could Not Stop for Death" and answer the question. Because I could not stop for Death – He kindly stopped for me – In the
Choose one of the cultural holidays listed in Part A (the options of holidays to choose from are in the image) and investigate it further. Research the followin
Which area of the stage was out of view of the audience
At the beginning of january 2002, the price of ground beef was $1.70 per pound and the price of tuna fish was $2.20 per pound. for the following 15 months, the
Calculate the area of a circle of radius 7cm. One sector of this circle has an area of 49.5cm^2 What is the angle at the centre of this?
which best-selling book, written by angela duckworth, explains how success can be achieved by a combination of passion and persistence?
What is the name of one of the best-known novels by the brazilian writer paulo coelho?
standard precautions differ from transmission-based precautions in that standard precautions
What is 1984 about? Should I read it?
how to write essay describe your personal and/or career goals after graduating from uiuc and how your selected first-choice major will help you achieve them.?