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
sp2606 [1]
4 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]4 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
Travel agents are market intermediaries who make their living by gathering, organizing, and dispensing information about travel-
Oliga [24]

Answer:

A. Travel agents routinely use the internet and other new information technologies as sources for the information they obtain for their customers

Explanation:

These travel agents also have access to this information on the Internet  and because of it, they know the prices these airlines and hotels put up on their website and regulate their own prices, making it cheaper, so as to remain in business.

The travel agents can also gather, organise and dispense travel related information at a more affordable rate. These travel agents will access the travel and booking information from the airlines, hotels, etc and go ahead to make logistics that will make the journey easier, cheaper and more enjoyable to their customers.

The advent of travel information on the internet that is also accessed by the travel agents will not necessarily reduce the importance of the travel agents, it will merely make them offer better services because they now have a serious competitor which is ease of information on the internet.

3 0
3 years ago
User 2.0 is most likely to Multiple Choice passively read and search for content. depend on content creators and avoid expressin
Ahat [919]

User 2.0 is most likely to: use the Internet for social connection.

<h3>What is User 2.0?</h3>

User 2.0 which is an aspect of Web 2.0 defines the latest form of the internet that allows users to interact with each other. This form of the internet is easy to use and requires participation by users.

So, a possible feature of User 2.0 will be the ability to use the internet for socialization.

Learn more about User 2.0 here:

brainly.com/question/3913924

5 0
3 years ago
Which careers require completion of secondary education, but little to no postsecondary education? Mathematical Technicians and
Masteriza [31]

Answer:

Nondestructive Testing Specialists and Surveying Technicians

3 0
3 years ago
Read 2 more answers
2 When you add text with the Text Tool, __________. the text is added to the current layer a new floating selection layer is cre
Basile [38]

Answer:

A new floating selection layer is created

Explanation:

In a graphic design software for example like CorelDraw, if  a text tool is used to add text, a new floating selection layer is created in which, the text is inserted.

8 0
3 years ago
Does anyone know any nitro type hack??
alexgriva [62]

Answer:

yes nitro hack is where they time your hacking skills

5 0
4 years ago
Read 2 more answers
Other questions:
  • Consider the situation you addressed in the previous question. Create numeric cost estimates for each of the costs you listed. C
    10·1 answer
  • Which of the following statements is​ FALSE? A. Security is a huge concern for nearly all organizations with private or propriet
    14·1 answer
  • Which actions can be performed on tables in Word? Check all that apply.
    13·2 answers
  • Write a program which reads in a single integer 0 &lt;= n &lt; 30 and prints out the factorial of n. Factorials get very big ver
    9·2 answers
  • A client is asking for a printing solution that will print three sheets of paper with identical information on each page with a
    13·1 answer
  • What are the best app development companies in Dubai?
    8·1 answer
  • A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To ac
    5·2 answers
  • What is the web page path on the web server for the URL:
    12·1 answer
  • What are building blocks? Select three options.
    14·1 answer
  • Click this link to view O*NET’s Work Activities section for Manicurists and Pedicurists. Note that common activities are listed
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!