1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
melamori03 [73]
3 years ago
6

Given an array arr of type int , along withtwo int variables i and j , write some code thatswaps the values of arr[i] and arr[j]

. Declare anyadditional variables as necessary.
Computers and Technology
1 answer:
nignag [31]3 years ago
4 0

Answer:

Hi! I suppose that no matter the programming language that you need the algorithm, so I will do in pseudo-code.

 

myArray [int] = [1,2,3,4,5,"Hello","World"];

int i = 5;

int j = 2;

// Save the previous value before the swap

aux1 = myArray[i];

aux2 = myArray[j];

// Swap i & j

myArray[j] = aux1;

myArray[i] = aux2;

print(myArray)

// Out : myArray = [1,2,"Hello",4,5,3,"World"]  

Explanation:

The trick is to save in two variables the previous value of the two position before change the array, just like that you can change the array and make the swap without lost the values.

I hope it's help you.

You might be interested in
Describe the type of gameplay seen during early video games (ex. Spacewar!, Pong).
Elina [12.6K]
  • Sandbox. ...
  • Real-time strategy (RTS) ...
  • Shooter (FPS and TPS) ...
  • Multiplayer online battle arena (MOBA) ...
  • Role-playing games (RPG, ARPG, and more) ...
  • Simulation and sports.

<em>-</em><em> </em><em>BRAINLIEST</em><em> answerer</em>

3 0
3 years ago
Read 2 more answers
What is the name of the mvost powerful battery
sergij07 [2.7K]
Optima battery because it is stronger than a factory battery
6 0
3 years ago
Which one of the following items would you be most likely to keep in a database ?
DerKrebs [107]
C.) Payroll records. These are the most extensive and data-intensive.
8 0
3 years ago
What is the operation of an earth leakage tester
Vladimir [108]

In any electrical installation, some current will flow through the protective ground conductor to ground. This is usually called leakage current. Leakage current most commonly flows in the insulation surrounding conductors and in the filters protecting electronic equipment around the home or office. So what's the problem? On circuits protected by GFCIs (Ground Fault Current Interrupters), leakage current can cause unnecessary and intermittent tripping. In extreme cases, it can cause a rise in voltage on accessible conductive parts. 


5 0
3 years ago
100 POINTS + BRAINLYEST FOR FIRST PERSON THAT GETS IT RIGHT!!!! While writing a formula, what are some ways to insert a cell ref
nexus9112 [7]

Answer:

Line second and third i.e, "typing the cell name, like "B4"  and clicking the cell to reference " the correct answer.

Explanation:

It relates to some kind of set of cells on the worksheet, which could be used to calculates the formula. It also helps to locate the information, which you want to analyze in the calculation. It can also provide the cell reference in  more than one formula in the same worksheet, that relates to Information on many other workbooks, and wrong choices can be described as follows:

  • Hovering provides the basic details, in which we hover, that's why it is wrong .
  • Zooming is used in projection, it can't be used in the cell reference, that's why it is wrong.
7 0
3 years ago
Read 2 more answers
Other questions:
  • What will happen if you change data that is used in a formula
    10·1 answer
  • What is the part of the computer system that receives inputs, directs those inputs to the processor, and redirects the processed
    14·1 answer
  • Nonvolatile in the context of data storage means ________________. a. the data can't be changed in a data warehouse. b. the data
    11·1 answer
  • Explain the steps users can take to maintain an operating system
    15·1 answer
  • Write a function shampoo_instructions() with parameter num_cycles. If num_cycles is less than 1, print "Too few.". If more than
    7·1 answer
  • Solve a single producer, single consumer problem using wait() and notifyAll(). The producer must not overflow the shared buffer,
    5·1 answer
  • A folder has been shared with other users and set to read-only. What does this mean for users?
    12·2 answers
  • Which of the following terms best describes the product development life cycle process?
    6·2 answers
  • Procedural programs specify instructions that a processor must execute to perform computations. These programs sometimes consist
    11·1 answer
  • PLEASE HELP WILL GIVE BRAINLIEST!!!’
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!