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
juin [17]
3 years ago
6

Reversing the elements of an array involves swapping the corresponding elements of the array: the first with the last, the secon

d with the next to the last, and so on, all the way to the middle of the array. Given an array a and two other int variables, k and temp, write a loop that reverses the elements of the array. Do not use any other variables besides a, k, and temp.
Computers and Technology
1 answer:
Ksivusya [100]3 years ago
4 0

Answer:

// Assume that all variables a, n, temp have been declared.

 // Where a is the array, n is the array length, temp is a temporary

 // storage location.

 // Cycle through the array a.

 // By the time the loop gets halfway,

 // The array would have been reversed.

 // The loop needs not get to the end of the array.

 // Hence, the loop ends halfway into the array i.e n/2.

 for (int k = 0; k < n / 2; k++) {

   

  // Swap first and last, second and next-to-the-last and so on

  temp = a[k];

  a[k] = a[n - k - 1];

  a[n - k - 1] = temp;

 }

Explanation:

Carefully go through the comments in the code.

Hope this helps!

You might be interested in
Which statements best describe slaves in ancient times? Select all that apply.
Romashka-Z-Leto [24]

Answer:

Slaves are the people thought as conquered People

Explanation:

In ancient times, slaves works without any remunerations. These people are captured or purchased by rich peoples. Their whole life spends in slavery. The people who are also prisoners of wars worked as slaves for their rest of the life.

5 0
2 years ago
The pseudoinstructions that are available in an assembly language programming environment usually found in the Select one: a. CP
mafiozo [28]

Answer:

b

Explanation:

CPU manual provides guides to use a CPU.

Assembler manual provides guide on how to use an assembler and so is the case for compiler.

For a particular machine, it set of instructinos are available with the programmer.

6 0
2 years ago
Homework: Insertion Sort
Serga [27]

Answer:

Explanation:

I have written the code in Java. It contains the class Insertion Sorter which has the InsertionSort function. This function uses the insertion sort algorithm to sort a comparable array and if it fails to do so for whatever reason it throws an Illegal ArgumentException. If it sorts the array correctly it returns the number of changes that needed to be made in order to correctly sort the array. Due to technical difficulties I have attached the code as a text document below and proof of output in the picture below as well.

3 0
2 years ago
Intellectual ______ is the legal term for ownership of intangible assets such as ideas, art, music, movies, and software.
SOVA2 [1]

Answer:

<u>Property</u>

Explanation:

Intellectual Property (IP) is the lawful protection of human idea/intellect by unauthorised users. These human intellects are intangible assets that have both moral and commercial value. They include ideas, art, music, movies, software e.t.c.

Common types of Intellectual property include

  • Copyrights
  • patents
  • Trade Marks
  • Trade Secrets
5 0
2 years ago
Read 2 more answers
How do design elements and color work together on a web page?
KiRa [710]

Answer:

The answer I believe is: 2. Both Enhance visual appeal.

Explanation:

4 0
2 years ago
Other questions:
  • Lucy has to move data from column A to column N in a worksheet. Which keys should she select to move data in the same worksheet?
    7·2 answers
  • How to Print output in JavaScript
    8·1 answer
  • A growing number of large organizations have built internal Web sites that provide opportunities for online social networking am
    7·1 answer
  • Which of the following hacker attacks against wireless networks are virtually undetectable?
    12·1 answer
  • ____ documents consist of the text to be displayed on a Web page, together with a number of special characters: tags that achiev
    14·1 answer
  • Justine was interested in learning how to play the piano. Before she was allowed to even play the piano, she has had to learn
    15·2 answers
  • What blockchain implementation resulted from bitcoin’s rejection of a recommendation to enhance its scripting language support?
    9·1 answer
  • What are the steps in preparing a bootable USB installer?​
    11·1 answer
  • Hey, how do we get our warnings removed? I got one and I didn't realize that what I did was wrong.
    6·2 answers
  • When a user problem cannot be solved by the help desk at the first level of resolution, the problem is ___________ to the second
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!