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
You connect three 0.5 volt lights in series. Each light has a resistance of 25ohms. Answer the following.
viktelen [127]
1. 3 times the light voltage, ie., 3*0.5 = 1.5V
2. Total R = 3*25 = 75Ω, V=1.5V, I = V/R = 1.5/75 = 20 mA
3. A 1.5V battery (e.g., an AA battery) with a charge of at least 20mAh. AA batteries should be able to handle this easily.
7 0
4 years ago
How to drive more website traffic?
lidiya [134]

Hello there,

How to drive more website traffic?

Answer: Advertise

8 0
4 years ago
Which Of these best describes what a binary digit can store?
Sholpan [36]

Answer:

A

Explanation:

binary is in the root of 2 so it's only having values 1 and 0

8 0
3 years ago
You use the same five shell functions every day and are looking for a way to ensure they are available as soon as you log into y
ANTONII [103]

Answer:

.c. Load them via your login script.

Explanation:

Given that using functions in shell scripts enhances programming output and login script comprises the functions and statements required to effectively execute at any given time the user logs into their account.

Hence the moment these functions are formulated, they are then executed through a single command statement thereby reducing the time of re-writing another set of code repeatedly in every program.

Therefore, in this case, what you can do is to "Load them via your login script."

4 0
3 years ago
What is the name of the organization responsible for assigning public ip​ addresses?
Veseljchak [2.6K]
Comcast,at&t,and Verizon
8 0
3 years ago
Other questions:
  • The first row of a table is often called the _____ row.
    12·2 answers
  • Which is better to use for cleaning electronics, Ethyl alcohol vs isopropyl alcohol?
    14·1 answer
  • The __________ contains a list of all the resources owned by the library.
    7·1 answer
  • How to be professional in graphic design without CAD?
    5·1 answer
  • How does the View tab of the ribbon allow you to look at a document?
    9·1 answer
  • Convert 3BA.25 (base 14) to base 6 ? Show all arithmetic in decimal
    5·1 answer
  • Without net neutrality, which of these situations might occur? (Select all that apply.) a cable company might charge different b
    5·1 answer
  • Amanda would like to add text to a slide in her presentation. Select all of the correct methods she can use to add text.
    6·1 answer
  • In python, sorry if it’s blurry
    13·2 answers
  • 1. Write the full forms of the following.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!