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
Armando is trying to decide how he will alert players that the game is over in the new video game that he is designing. He is co
mojhsa [17]

Answer:

He is working on the outcome

Explanation:

Because this is the outcome if you fail or die and the other objectives are the following

operation: A single objective in a level of the the whole game

obstacles: Trying to stop the player like blocks or walls or traps

objective:The main goal of the game

8 0
3 years ago
"Inheritance is the process by which a new class - known as a _________ - is created from another class, called the ____________
Novay_Z [31]

Answer:

child class

parent class

Explanation:

"Inheritance is the process by which a new class - known as a __child class__ - is created from another class, called the __parent class__. "

3 0
3 years ago
What does it mean to “declare a variable”? create a variable use a variable share a variable modify a variable
lara [203]

You are defining the variable

6 0
3 years ago
Read 2 more answers
Which option is available when reviewing changes and using the Accept command in the Compare group?
Zarrin [17]

Answer: Accept only one at a time, all on a slide, or all changes in a presentation.

Explanation:

Took the review

6 0
3 years ago
Read 2 more answers
BRAINLY, WHY CAN'T I COMMENT ANYMORE(what did I do to deserve this)
Crank

Answer:

Did you write something inappropriate

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Excel 2016 is primarily what type of program?
    15·1 answer
  • If you need to multiply 400, 2, and 1 ½, what would you type on the numeric keypad?
    9·2 answers
  • Which of the following is an example of a word processing program?
    11·2 answers
  • What type of network is a private network that belongs to an organization that can only be accessed by approved internal users?
    15·1 answer
  • An Ethernet network, all data travels across the network and between computers in which form or unit?
    12·1 answer
  • A website that sells high-end ties notices that its ads are showing up for searches that include "cheap". Because its ties are e
    14·1 answer
  • Which statement does not describe the guidelines for the use of text in presentation programs?
    7·1 answer
  • Shira’s Shoes sold 875,000 pairs of sandals in June, which was 70% of the total number of shoes sold. How many shoes did the com
    14·2 answers
  • web browsers save website information in their _________, which helps the site load faster on future visits.
    11·1 answer
  • What term is used to describe selecting and viewing information in a database?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!