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]
2 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]2 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
In your opinion is it more beneficial to have many folders or is it better to nest subfolders
Semmy [17]
I dont think it matters just as long you have all your things to work it doesnt matter if you have to tape it on your back
7 0
2 years ago
PLS HURRY!! This OS introduced a very cool GUI that had animations and transparencies.
Mumz [18]

Answer:

I think Windows 98 or XP it's one of those

Explanation:

6 0
3 years ago
Identify the correct XHTML syntax for inserting an image as a hyperlink from the options provided. A. book.gif B. C. D.
mariarad [96]

Answer:

The Correct syntax for inserting an image as hyperlink is given in explanation section

Explanation:

To make an image act as a hyperlink, place the image element within the HTML anchor "<a></a>"  element.

The syntax of inserting image hyperlink in XHTML is given below.

<a href = "link_that_can_be_accessible"><img src="source of image" alt="display name if image not shown in the browser" border="0"/></a>

for example lets insert image as hyperlink

<a href="ajax.html"><img src="logo.gif" alt="AJAX" border="0" /></a>

The default appearance is a blue border around the image. Specifying border="0" removes the border around the image.

if you want to insert image from another folder then the image hyperlink looks like this:

<a href="ajax.html"><img src="/images/html5/logo.gif" alt="AJAX" border="0" /></a>

If you want to insert image from another server then image hyper link looks like this:

<a href="ajax.html"><img src="https://www.myExample.com/images/html5/logo.gif" alt="AJAX" border="0" /></a>

4 0
3 years ago
Which type of network involves buildings in multiple cities connecting to each other?
NeX [460]

Answer:

Power lines

Explanation:

Because their everywhere

4 0
3 years ago
How many years does it take in total to complete Bachelor’s, Master’s, and Phd in CS?
muminat

Answer:

3 years of study - Bachelor's degree

2 years of research - Master's degree

3 years of research to earn a PhD

So, On total it would take 8 years!

7 0
3 years ago
Other questions:
  • What are some measurements used to determine water waste from leaking faucets?
    10·1 answer
  • What feature could you use to automatically shade cells containing a negative value in red?
    7·2 answers
  • Write a program that produces a Caesar cipher of a given message string. A Caesar cipher is formed by rotating each letter of a
    14·1 answer
  • 5. The stage of engine operation when both the intake and exhaust valves are closed is the _______ stage.
    5·1 answer
  • While designing your network's VLAN topology, your team has decided to use a centrally managed DHCP server rather than creating
    8·1 answer
  • Applications software is also known as
    14·2 answers
  • What are the defenses to protect against these attacks?
    13·1 answer
  • Which of these is NOT an example of a GUI?
    7·1 answer
  • ¿Cuál es la diferencia entre una plataforma educativa y una tutoría?
    7·1 answer
  • Explain why you do not need expensive equipment to take pictures or record video?
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!