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
WINSTONCH [101]
3 years ago
11

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, an int variable n containing the number of elements in 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, n, k, and temp.
Computers and Technology
1 answer:
Debora [2.8K]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;

 } // End of for loop

Explanation:

Explanation has been given in the code in form of comments. Kindly go through the comments in the code.

Hope this helps!

You might be interested in
What is the potential outcome for an author if she uses a word without realizing its connotation? she may write something that s
zubka84 [21]

A potential outcome for an author who uses a word without realizing its connotation is: A. she may write something that she does not mean.

<h3>What is connotation?</h3>

Connotation refers to the quality, feeling or an idea which a word brings to the mind of a reader or listener, as well as its literal, dictionary or primary meaning.

This ultimately implies that, a potential outcome for an author who uses a word without realizing its connotation is that he or she may write something that she does not mean or pass across an information she didn't intend to.

Read more on connotation here: brainly.com/question/20236939

#SPJ1

3 0
2 years ago
Define the following <br>chatting <br>browsing <br>E-commerce​
vova2212 [387]

Answer:

- <em>chatting</em>: real-time communication via keyboard between two or more users on a local network (LAN) or over the Internet.

- <em>browsing</em>: refers to reading and scanning through data; commonly used to describe when a user reads through pages on the Internet and is also often referred to as surfing.

- <em>e-commerce</em>: commercial transactions conducted electronically on the internet.

5 0
3 years ago
Which of these statements sums up why the computer is the most visible and
Andreyy89

Statement A is true, that is computers are used in all digital technologies.

Explanation:

  • Among the given statement the most appropriate statement to choose the computer as the most visible and pervasive product of the digital age is that computers are used in all digital technologies now.
  • And other statement are false or not valid as computers are not only used in United states
  • Computer is not the only form of communication.
  • And computers are not the only technological devices that we use now.

6 0
4 years ago
30 POINTS FOR THE ANSWER
vladimir2022 [97]

The possible solutions are:

  • Ask for a printed or click on proof to get the  right color match.
  • One can use Pantone colors as it aids with color matching.

<h3>How do one do the above?</h3>

Computers is known to often use the same data and it often uses it to bring up clarity or light up pixels on its screen.

Therefore to get the result above, one need to check system preference system setting to get different brightness and color settings.

Therefore, The possible solutions are:

  • Ask for a printed or click on proof to get the  right color match.
  • One can use Pantone colors as it aids with color matching.

Learn more about printed colors from

brainly.com/question/1548113

#SPJ1

4 0
2 years ago
A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-lif
Elena L [17]

Answer:

// here is code in java.

import java.util.*;

class Solution

{

// main method of class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // declare variable

         double caffeine;

    // scanner object to read input from user

       Scanner scr=new Scanner(System.in);

       System.out.print("Enter the initial amount of caffeine:");

        // read the initial amount of caffeine

           caffeine=scr.nextDouble();

          // calculate amount of caffeine after 6,12,18 hours

          for(int i=1;i<=3;i++)

          {

               System.out.println("After "+ i*6+" hours:"+(caffeine/2)+" mg");

               // update the caffeine after every 6 hours

               caffeine=caffeine/2;

          }

                 

   }catch(Exception ex){

       return;}

}

}

Explanation:

Create a variable "caffeine" to store the initial amount of caffeine given by user. Run a loop for three time, it will calculate the amount of caffeine left after every 6 hours.First it will give the amount of caffeine left after 6 hours, then caffeine left after 12 hours and in last caffeine after 18 hours.

Output:

Enter the initial amount of caffeine:100

After6 hours:50.0 mg

After12 hours:25.0 mg

After18 hours:12.5 mg

8 0
4 years ago
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
  • A network supplies programming and services to a series of local tv stations, or _____, which contract to preempt time during sp
    7·1 answer
  • How does scarcity affect what gets produced
    5·1 answer
  • 2. Write a program that askes the user to enter a positive number not greater than 10.the program then must display the triangle
    12·1 answer
  • Select the strategies below that are likely to increase audience attention.
    14·2 answers
  • A stigma is
    8·2 answers
  • ____________________ software is a type of security software designed to identify and neutralize web bugs, ad-serving cookies, a
    8·1 answer
  • Question 12 (1 point)
    6·1 answer
  • WILL GIVE BRAINLIEST TO HELPFUL ANSWERS!
    8·1 answer
  • Versiones del Moodle
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!