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
____ is a method of querying and reporting that takes data from standard relational databases, calculates and summarizes the dat
IgorLugansk [536]

Answer: Online analytical processing

Explanation:

Online analytical processing(OLAP) is the method through which multi-dimension analytical queries can be resolved.User can attain selected query data as per their selection and then assess and analyze them from different view point.

  • It helps in viewing and reporting , planning ,performing analytical calculation, collecting data in data cubes etc.
  • Other options are incorrect because data adjacency, Ad hoc reporting ,data segregation and E-discovery are not the mechanism through which query and storage of data in data cubes take place.
  • Thus, the correct option is online analytical processing
3 0
3 years ago
What is a common use for append queries?
Karo-lina-s [1.5K]

Answer:

You use an append query when you need to add new records to an existing table by using data from other sources. If you need to change data in an existing set of records, such as updating the value of a field, you can use an update query.

6 0
3 years ago
Read 2 more answers
PASSAGE: The picnic had been scheduled for weeks in advance. The Morris family was looking forward to some fun and relaxation wi
Mekhanik [1.2K]

Answer:

B) The sky began to darken and rumble.

Explanation:

B) The sky began to darken and rumble.

It seems they have arranged it big. Hence, the money is not a problem. Any number of people can be invited,

The problem was certainly that the rain was about to come as sky turned dark and rumble. And hence, this answer as its what created tension.

7 0
3 years ago
Immigrants are allowed to enter the country to work when they have a(n)
Roman55 [17]

Answer:

D. a Visa

Explanation:

4 0
3 years ago
Assume that ip has been declared to be a pointer to int and that enrollment has been declared to be an array of 20 elements . As
Vitek1552 [10]

Answer:

ip = enrollment + section;

Explanation:

The variable ip has been declared to be a pointer to int.

int * ip;

The variable enrollment has been declared as an array of 20 elements .

int enrollment[20];

The variable section has been declared as an int.

int section;

In order to make ip point to the element in the array indexed by section, we can use the following statement :

ip = enrollment + section;

This will make ip point to enrollment[section].

5 0
3 years ago
Other questions:
  • Prompt the user for an automobile service. Each service type is composed of two strings. Output the user's input. (1 pt) Ex: Ent
    9·1 answer
  • What is the part of the computer system that receives inputs, directs those inputs to the processor, and redirects the processed
    14·1 answer
  • Consider sorting n numbers stored in array A by first finding the smallest element of A and exchanging it with the element in A[
    13·1 answer
  • What is meant by backing up files through cloud computing?
    5·2 answers
  • What's the main piece of information you look for in an e-mail message you're investigating??
    14·2 answers
  • Please choose the correct option please tell fast​
    9·1 answer
  • A typical day in programming and software development would involve
    7·1 answer
  • All banks follow the same guideline for determining if an applicant qualifies for a loan.
    13·1 answer
  • What's the difference between a robot and a machine?
    7·1 answer
  • Mario is designing a page layout for a sports magazine, and he decides to add the image of a cyclist. Which principle of page la
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!