answer.
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
sp2606 [1]
2 years ago
10

An array of ints, arr, has been declared and initialized. Write the statements needed to reverse the elements in the array. So,

if the elements were originally 5, 13, 4, 97 then after your code executes they would be 97, 4, 13, 5.

Computers and Technology
1 answer:
Yuki888 [10]2 years ago
5 0

Answer:

The sample output is below.

The code is attached.

Explanation:

Sample Output:

Original array is: 1 2 457 4 Reversed array is: 4754 2 1

Code to copy:

import java.io.*;

class Main

{

    /*Define the function revArray passing the array

      and its indices.*/

    static void revArray(int arr[], int start, int end)

    {

         /*Declare an integer variable to store the

           first index.*/

         int temp;

         //Check if array is empty.

         if (start >= end)

             return;

         //Store the first index value.

         temp = arr[start];

         //Swap the last index to first index.

         arr[start] = arr[end];

         //Store the temp value to last index.

         arr[end] = temp;

         /*Call the function recursively to swap

           rest of the values.*/

         revArray(arr, start+1, end-1);

    }  

    public static void main (String[] args)

    {

         //Declare and initialize array.

         int[] arr = {1,2,4,5,7,4};

         /*Declare an integer variable to store the

         * length of array.

         */

         int count=0;

         //Set the length of array to count.

         for(int i=0;i<arr.length;i++)

             count++;

         System.out.println("Original array is:");

         ///Print the original array.

         for(int i=0; i<count;i++)

         {

             System.out.print(arr[i]+" ");

         }  

         /*Call the function to reverse the values in

         * the array itself.

         */

         revArray(arr, 0, count-1);

         System.out.println("\nReversed array is:");

         ///Print the reversed array.

         for(int i=0; i<count;i++)

         {

             System.out.print(arr[i]+" ");

         }  

    }

}

You might be interested in
Which best compares and contrasts visual and performing arts? Both careers use communication skills; however, people involved in
Vlad1618 [11]

Answer:

Both careers speak to an audience; however, people involved in the performing arts speak only to a live audience.

Explanation:

sorry im late but im not sure

3 0
2 years ago
Read 2 more answers
They predicted another cold day in Seattle. They predicted another windy day in Seattle. Combine the sentences into one sentence
VLD [36.1K]

Answer:

They predicted another cold day in Seattle and another windy day in Seattle.

4 0
2 years ago
your company decides to implement a RAID-5 array on several file servers. Which feature is provided by this deployment
Novay_Z [31]

Answer:

High availability

Explanation:

RAID-5 array is defined as a redundant array for independent disk configuration which makes use of the disk striping with the parity. It consists of a minimum three disk drives and it uses the data striping and the parity data to provide the redundancy.

RAID 5 is a powerful tool to ensure integrity of the data. It provides both performance as well as security to the data.

In the context, "high availability" is the feature that is provided by the deployment of RAID 5 array on the several file services.

4 0
1 year ago
Following are groups of three​ phrases, which group states three ways to improve your​ concentration?
andreev551 [17]
I believe its <span>c-set up a study​ space, preview your​ materials, create a routine</span>
3 0
1 year ago
Why is it important to back up data on a computer before you burn-in test the cpu?
katen-ka-za [31]
A burn-in test is a test which is usually performed on a system or component by running it for a long time in order to bring out any errors or system failures etc. 
While doing it on CPU the data must be backed up as any kind of error or failure may result in the loss of data, at time systems can be repaired to retrieve data but still there is no guarantee, backing up is the best option.
5 0
1 year ago
Other questions:
  • Is used to process certificates and private/public key information?
    12·1 answer
  • When performing actions between your computer and one that is infected with a virus which of the following offers no risk becomi
    5·1 answer
  • Because of the density of vehicle in urban areas, you should ____.
    8·2 answers
  • . Write a recursive function names factorial to compute the factorial of the parameter. Also write the main function, where you
    15·1 answer
  • 14.28. Consider the relation R, which has attributes that hold schedules of courses and sections at a university; R = {Course_no
    7·1 answer
  • Chris accidentally steps on another student’s foot in the hallway. He apologizes, but the other student does not want to hear it
    13·2 answers
  • Jen is trying to discover if a motor has failed windings. What sort of test can she do.
    6·1 answer
  • Your company has decided to replace several hundred hard drives. It would like to donate the old hard drives to a local school s
    11·1 answer
  • Joe, Kate and Jody are members of the same family. Kate is 5 years older than Joe. Jody is 6 years older than Kate . The sum of
    11·2 answers
  • Identify the tips to create a well-designed digital portfolio.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!