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]
4 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]4 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
IF YOU GET THIS RIGHT U GET BRAINLIEST
Bumek [7]
False
                                                     false
 its false im fr 
5 0
4 years ago
Read 2 more answers
To download your presentation as pictures, choose this option.
VARVARA [1.3K]

Answer:

Download as Images

Explanation:

Copy is unspecified

Images is a synonym of pictures

PDF is a file type

ODP is a presentation file

8 0
3 years ago
Read 2 more answers
Which best describes the benefits of renting a home?
WARRIOR [948]
The benefits are that you don't have to worry if something breaks from like a water leake or a storm and get destroyed the home owners have to pay
7 0
4 years ago
Read 2 more answers
The template code provided is intended to check whether an integer entered by the user is outside of the range 20-29 (inclusive)
Pavlova-9 [17]

import java.util.Scanner;

public class JavaApplication60 {

   

   public static void main(String[] args) {

       Scanner scan = new Scanner(System.in);

       System.out.println("Enter a number in the twenties");

       int num = scan.nextInt();

   if(num >= 30 || num <= 19){

       System.out.println("That's not in the twenties!");

       num = 25;

   }

   System.out.println("Your number is " + num);

   }

}

This is the complete code including the main class and main method. I hope this helps!

3 0
3 years ago
Have you searched Buzz Ch.at on playstore​
deff fn [24]

Answer:

Reorder terms.

y=52x−1

Cancel the common factor of 22.Factor 22 out of −2-2.

y−4=5x2+52⋅(2(−1))y-4=5x2+52⋅(2(-1))

Cancel the common factor.

y−4=5x2+52⋅(2⋅−1)y-4=5x2+52⋅(2⋅-1)

Rewrite the expression.

y−4=5x2+5⋅−1y-4=5x2+5⋅-1

Multiply 55 by −1-1.

y−4=5x2−5

3 0
3 years ago
Other questions:
  • Question # 6
    13·1 answer
  • Prodeff, an online project management software, is available at a price of $1 per use. The software requires the user to enter t
    13·1 answer
  • How many inches do a tire have to be to sometimes be refer as bald of balding tries
    14·1 answer
  • 14. Which of the following statements is true? A. The most secure email message authenticity and confidentiality isprovided by s
    11·1 answer
  • Once the human body stops moving in a crash, the internal organs stop as well. True or false?
    11·1 answer
  • Given two integer variables distance and speed, write an expression that divides distance by speed using floating point arithmet
    13·1 answer
  • /* Write a method called fractionSum that accepts an integer parameter n and
    5·1 answer
  • Https://www.blooket.com/play?id=300932<br> please
    8·2 answers
  • Printed versions of your presentation that contain the slides and blank lines below are called
    9·1 answer
  • A ____ attack is much more substantial than a dos attack because of the use of multiple systems to simultaneously attack a singl
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!