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
Antivirus software products require that you update _____ on a regular basis.
Inga [223]

The Correct Answer is

Virus Definitions

Please Like

7 0
3 years ago
What does it mean when your phone says system ui has stopped?
wel
It means hat the CPU is taking o much of what the phone can normally do try delete some apps or close apps your not using 
8 0
4 years ago
Which network protocol is used to handle delivery of information
rodikova [14]

Answer:

TCP

Explanation:

TCP stands for Transmission Control Protocol a communications standard that enables application programs and computing devices to exchange messages over a network. It is designed to send packets across the internet and ensure the successful delivery of data and messages over networks.

6 0
2 years ago
Marking brainliest please help
andreyandreev [35.5K]

Thye firsat one sis the corerest

3 0
3 years ago
The variable strFirst's scope is _____.
sp2606 [1]
Pretty sure it’s d, hope this helps
3 0
3 years ago
Other questions:
  • Given parameters b and h which stand for the base and the height of an isosceles triangle (i.e., a triangle that has two equal s
    8·1 answer
  • What are the cause of eye strain during computer usage?
    7·1 answer
  • False when you tap or click the ‘decrease font size’ button, excel assigns the next lowest font size in the font size gallery to
    13·1 answer
  • Objects of the calculator class require no additional information when created. define an object named calc, of type calculator.
    14·2 answers
  • Raul in Colombia can enter data into a spreadsheet. Olivia in England can access the spreadsheet a few minutes later and use Rau
    7·1 answer
  • Someone please help will mark as brainliest
    8·2 answers
  • NEED ANSWER ASAP. CORRECT ANSWER GETS BRAINLIEST! TY
    5·1 answer
  • Of the people working in concert with security teams to ensure data quality and protection, the head of information management i
    5·1 answer
  • Pls help me pls I’m struggling
    11·1 answer
  • For a web application we associate a web server, for a mobile application we associate a mobile server. for a decentralized appl
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!