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
If a protocol is routable which tcp/ip layer does it operate at\
ikadub [295]
Layer 3, the Network Layer, just like the OSI model.
6 0
3 years ago
Why are security measures protecting gdp data so strict?
Semenov [28]
The stock market would behave very differently if people had easy access to that data.
7 0
3 years ago
Which software application would you use to calculate and manipulate numerical data?
Basile [38]
The Software App That I Would Use Would Be NumericalDataHelp.com ... I Use that all the time ... If you cant find it just search in Google or Firefox Numerical Data Help and then you should be able to find some help there ... I hope that this helped !!! If it did mark me brainiest 
5 0
3 years ago
An application with a 150 GB relational database runs on an EC2 Instance. While the application is used infrequently with small
kupik [55]

Answer:

the bandman is hered that mybaddba

4 0
3 years ago
Create a statement trigger called "bt_maj_adv_trigger" that would be work with both advisor as well as major table. If a record
denis23 [38]

Answer:

Create or replace trigger at_advisor

after delete or insert or update on advisor

for each row

Begin

  if inserting

then

  insert into

     log_maj_adv

  values

     (

        user, :new.adv_code, sysdate, 'insert'

     )

;

elsif deleting

then

  insert into

     log_maj_adv

  values

     (

        user, :new.adv_code, sysdate, 'delete'

     )

;

else

  insert into

     log_maj_adv

  values

     (

        user, :new.adv_code, sysdate, 'update'

     )

;

end if;

End;

Explanation:

as per above answer.

5 0
3 years ago
Read 2 more answers
Other questions:
  • A publisher has a text-only leader board on top of a page, and a text-only small square ad slot within the content of that page.
    7·1 answer
  • Which is the correct description of the first act in a classical game story structure?
    14·1 answer
  • Explain what a hypervisor application is and what it is used for. Pick a hypervisor application and list its requirements
    8·1 answer
  • Which of the following is a requirement for the Safety Data Sheet (SDS)?​
    5·1 answer
  • Which of the following translates packets so that the node can understand them once they enter through a port?
    5·2 answers
  • PLZZZ HELP!!! I’ll give brainliest
    12·1 answer
  • Pls help I will give lots of points
    9·1 answer
  • A set of blocks contains blocks of heights 1,2, and 4 centimeters. Imagine constructing towers of piling blocks of different hei
    15·1 answer
  • Which of the following will increase the level of security for personal information on a mobile device if the device is lost or
    7·2 answers
  • I re-made the human version of Daddy Dearest from Friday Night Funkin
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!