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
Gekata [30.6K]
2 years ago
15

Write the definition of a function reverse, whose first parameter is an array of integers and whose second parameter is the numb

er of elements in the array. The function reverses the elements of the array. The function does not return a value.
Computers and Technology
1 answer:
GrogVix [38]2 years ago
8 0

Answer:

The c++ function for reversing an array is given. The function is declared void since it returns no value.

void reverse( int arr[], int len )

{

   int temp[len];

   for( int k = 0; k < len; k++ )

   {

       temp[k] = arr[k];

   }

   for( int k = 0, j = len-1; k < len, j>= 0; k++, j-- )

   {

           arr[k] = temp[j];

    }

}

Explanation:

The reverse function uses another array to reverse the elements of the original array.

An integer array is declared, temp[len], having the same length as the input array.

int temp[len];

To begin with, the elements of the input array are copied in the temp array.

for(int k = 0; k < len; k++ )

{

       temp[k] = arr[k];

}

Next, the elements of the input array are given new value.

The temp array, in reverse order, is copied into the input array.

for( int k = 0, j = len-1; k < len, j>= 0; k++, j-- )

{

           arr[k] = temp[j];

}

The above for loop makes use of two variables simultaneously.

While the array, arr is proceeding from first element to the next, the array temp begins with the last element and goes down to the previous element.

Now, the input array, arr, contains the elements in reverse order.

The complete program is given.

#include <iostream>

using namespace std;  

 

void reverse( int arr[], int len );

void reverse( int arr[], int len )

{

   int temp[len];

   

   for(int k = 0; k < len; k++ )

   {

       temp[k] = arr[k];

   }

   

   for( int k = 0, j = len-1; k < len, j>= 0; k++, j-- )

   {

           arr[k] = temp[j];

   }

   

}

int main()  

{

   int len = 5;    

   int arri[len];    

   for( int l = 0; l < len; l++ )

   {

       arri[l] = l;

   }

   

   reverse( arri, len );    

   return 0;

}

You might be interested in
How long will it take to transfer 1GB data on USB 2.0, on USB 3.0
cupoosta [38]

Answer:

Have a great day, Here is the answer to your question:

It will take around 18 seconds

Explanation:

So in principle 1GB of data to be uploaded running at peak speed is suggested to take around 18 seconds but in fact, DCD test results show USB 2.0 takes 3 minutes 18 seconds to complete a 1GB switch. Whereas USB 3.0 can accommodate up to 5gbps of data transferred-more than 10 times faster than its predecessor.

8 0
3 years ago
In this activity, you will submit the work you completed for the "Explore: Products" assignment. Type your response directly int
BabaBlast [244]

It should be noted that mate is the national beverage of countries such as Uruguay, Paraguay, and Argentina.

<h2>What is mate?</h2>

Mate tea is simply a beverage that is high in antioxidants and also contains caffeine.

It should be noted that mate is important as it raises morale, helps in sustaining the muscular system, and also allows an individual endure privations.

In conclusion, the drink is also usually taken by sportsmen.

Learn more about beverages on:

brainly.com/question/25884013

6 0
2 years ago
In asps, the code to tie the database to the web site is typically written in javascript or ____.
Dominik [7]
In asps, the code to tie the database to the web site is typically written in javascript or VBScript<span>(Visual Basic Script).
</span>VBScript is an interpreted script language from Microsoft<span> with syntax very similar to that of Visual Basic.
</span><span>Most often VBScript is used for Quick Test Professional (QTP), which is a test automation tool.</span>
4 0
3 years ago
3. How can you correct the color of your photos automatically?​
natita [175]

Answer:

use the lightroom

download the app haha

4 0
3 years ago
Read 2 more answers
How do you feel about the Furry Fandom?
gtnhenbr [62]
When you don’t know who or what that is, and I pop- lol I need a life
8 0
2 years ago
Other questions:
  • Given num_rows and num_cols, print a list of all seats in a theater. Rows are numbered, columns lettered, as in 1A or 3E. Print
    8·1 answer
  • You are responsible for performing all routine maintenance on your company's laser printers. Which of the following maintenance
    15·1 answer
  • Purpose Your goal is to create a design for a software interface. You will experience the scope of the design process from brain
    7·1 answer
  • _________function tells the cin object to skip one or more characters in the keyboard buffer.
    11·1 answer
  • Write a brief description of what the local authorities are recommending in the news people should do to protect themselves from
    8·1 answer
  • Select the correct answer.
    13·1 answer
  • Design a program takes as input, X, an unsorted list of numbers, and returns the sorted list of numbers in X. The program must b
    12·1 answer
  • The memory used by the CPU to temporarily hold data while processing is called _______. random access memory central processing
    5·1 answer
  • You are the Emergency Management Director of a small island nation. Your nation has come under Cyber-attack and the attackers ha
    7·1 answer
  • Select the WRONG statement about Slide Transitions.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!