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
Back wit another one, help !?<br><br>these are two different questions btw
trapecia [35]
Question 1: Best way is option 1, Worst way is option 4.

Question 2: Best way is option 4, Worst way is option 3

7 0
2 years ago
In a cross-site request forgery, what components help send a forged HTTP request? In a cross-site request forgery, browser _____
Mariana [72]

<u>Answer:</u>

<em>In a cross-site request forgery, browser </em><u><em>Link</em></u><em> help send a forged HTTP request.</em>

<u>Explanation</u>:

<em>CSRF is a kind of attack which compels the user to click on the unwanted links </em>or make him to perform some actions on the browser which the user is not intended to do so.

<em>They mainly target on Change request such as fund transfers, modifying their mail id’s etc</em>.

So they do all things by knowing Social engineering tricks and transfer the control of the <em>user to one another application created by the hackers and obtain the information and it is not just for theft of data. </em>

4 0
3 years ago
A virus has attacked your hard drive. Instead of seeing the Windows Start screen when you start up Windows, the system freezes a
irinina [24]

Answer:

Remove the hard drive from the computer case and install it in another computer.

Explanation:

This can allow us to stop the spread of virus and also may be the other computer can get our data safely despite of virus.

6 0
3 years ago
Consider the code block below. What is the value of amount when this method is called twice, the first time using cookieJar(7) a
Alex787 [66]

Answer: 29

Explanation:

The variable amount is given a initial value of 0

Therefore, the first method call:

cookieJar(7)

amount + cookieJar

amount = 0 + 7 = 7

And the value of 7 is returned for amount at the start of the block

Thus, when cookieJar is called the second time ;

cookieJar(22)

amount + cookieJar

amount = 7 + 22 = 29

And the value of 29 is returned for amount at the start of the block

4 0
3 years ago
Say you are running a program along with many other programs in a modern computer. For some reason, your program runs into a dea
swat32

Answer:

The OS deals with such deadlock to temporarily prevent resources from deadlocked processes. It is either it back off a process to some check point allowing preemption of a needed resource and restarting the process at the checkpoint later. Finally, successively kill processes until the system is deadlock free.

6 0
3 years ago
Other questions:
  • Which Game Is Better &amp; Favorite For You?
    12·2 answers
  • If your address is 10 B Street, what are the first three bytes in ASCII
    12·1 answer
  • You manage a server that users store their document files on. you are finding that some users are utilizing more space than they
    14·1 answer
  • Enzymes_____________.
    7·1 answer
  • The freemen's bureau was the U.S.' first ____ program.​
    14·1 answer
  • Time-management techniques work most effectively when performed in which order?
    7·1 answer
  • What are the services offered by web-based email?​
    12·1 answer
  • Fwee Pwoints Fwor You
    11·2 answers
  • Select the correct answer. Who takes care of the final layout of the product that meets the standards set by UX designers? A. we
    15·1 answer
  • Select the incorrect sentence from the options given below. *
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!