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
Super easy question but you have to think about it because it’s not that easy I’ll mark brainliest for first answer Explain the
kkurt [141]

Answer:

Databases are not that simple. Now we not only have a Data warehouse, but we also have the Data Lake as well. We also have NoSQL and SQL form of support with these modern databases. The JSON format is rocking. You can hence through JSON store the text, image, audio, video, etc in one go. And like the first five can be a text, the next five can be an image then again a text than video, and so on. And it is super easy to access them as well. Also, you can edit them quite easily as well. It's not that hard like the Lisp used to be in the past. And supermarket has a mix blend of the database. And modern databases like Data Lake can be very useful, undoubtedly.

You can store security type of requirements, like CCTV footage, each shop details like shop ID, Product list, shop type, electricity bill, hours of opening, floor, facilities, no. of employees, etc., and like this, we can have the details for the entire supermarket, and each shop there definitely. And we can perform various actions on behalf of each shop and market as well. The database can hence be very useful definitely

Explanation:

Please check the answer.

8 0
3 years ago
What are the pros and cons of the internet’s ability to access information
Shkiper50 [21]
THE PRO IS THAT IT ALLOWS PEOPLE TO RESEARCH INFORMATION. THE CON IS THAT PEOPLE ARE ABLE TO DO MEAN THINGS ON THE INTERNET. FOR EXAMPLE, CYBER-BULLYING. PLEASE HIT THE THANKS BUTTON. :)
3 0
3 years ago
Read 2 more answers
Imagine that you work for an organization that has no Internet use policy. Employees use the Internet in whatever way they want
Strike441 [17]

Answer: Yes

Explanation:

It would force the company to either enforce the policy and fire all of its employees.

8 0
1 year ago
In animation what is exaggerated to make the characters more intensely what they are​
aleksklad [387]

Answer:

Exaggerated used of the technique can produce a comical effect, while more realistic animation must time the actions exactly to produce a convincing result. Slow in and slow out. Adds more frames near the beginning and near the end of a movement, and fewer in the middle, to make the animation appear more realistic.

5 0
3 years ago
The device that concerts one type of signal to another is what​
chubhunter [2.5K]

Answer:

Transducer is a type of device that converts one type of signal into another.

6 0
3 years ago
Other questions:
  • Ok, so this isn't a tech question it's about a game, moomoo.io so don't hate on this if you don't know it, 40 points to whoever
    12·2 answers
  • You support Richman Investments, a brokerage firm that employs 20 brokers. Each broker has his own client computer, and the firm
    15·1 answer
  • Help me I'm so confused by this question
    7·1 answer
  • You are the leader of a team at work. What type of leader would you like to be – one that gets involved and works with the team
    15·2 answers
  • What services are used to help speed the development and deployment of internal custom applications?
    8·2 answers
  • Pls help me im confused prob more on the way
    6·1 answer
  • 60 POINTS IF YOU GET IT RIGHT
    6·2 answers
  • How to use access?<br> like working in access and bringing tables and stuff
    5·1 answer
  • IM a bit confused on what this is asking for exactly.
    14·1 answer
  • To optimize the flow of data into and out of the cpu, the modern mcc provides at least _______________ of data every time the cp
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!