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]
3 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]3 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
Go follow me plz i would appreciate it
aleksandr82 [10.1K]
Hejdjxuxudjjdjdbdbdbd
6 0
2 years ago
Read 2 more answers
CHKDSK is a system utility that is commonly found in Windows. What is CHKDSK? Use the Internet to research and write about CHKDS
Alex_Xolod [135]

chkdsk is a utility that you use to check for bad sectors on a hard drive , as far as how to run it you open the start menu go to your run bar and type chkdsk then follow the instruction on the screen .

6 0
3 years ago
Read 2 more answers
Suppose you have two RAID arrays, one implementing RAID 3, the other RAID 5. Each has 9 disk drives in its array. If the RAID 5
Snezhnost [94]

Answer:

48 is the answer

Explanation:

16×3 is the explanation for your question

8 0
3 years ago
CORYXKENSHIN IS BACKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK AND H
choli [55]

WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

8 0
3 years ago
Read 2 more answers
Based on what you know about the three platform architectures, which one would you choose to develop apps?
mario62 [17]

Answer:

The various elements of an app’s architecture

Building the ultimate app architecture

1. Determining the device

2. Considering bandwidth

3. Defining user interface

4. Navigation methods

There are numerous ways to navigate through app features, it is important for you to analyze which one’s good for your mobile application. The list includes:

Single view

Stacked navigation Bar

Tab controller

Scroll views

Search driven

Model controller

Gesture-based

Bringing a consistent flow to the architecture

7 0
3 years ago
Other questions:
  • What term is used to describe a chipset developed and promoted by the U.S. government from 1993 to 1996 as an encryption device
    9·1 answer
  • In this mode, your presentation will fill up the entire screen. Auto Default Standard Window
    6·2 answers
  • Nosql is a great technology for storing well-structured data. <br> a. True <br> b. False
    8·1 answer
  • To display the Color gallery, with the graphic selected, click the Color button in the ____ group on the PICTURE TOOLS FORMAT ta
    14·1 answer
  • Determine the exact output of the code $str = "The quick brown fox jumps over the the lazy dog"; echo strpos($str, 'fox');
    6·1 answer
  • Sometimes a database can contain "bad data," meaning incomplete, incorrect, inaccurate, or irrelevant records, which can be corr
    7·1 answer
  • Which of the following is a career that's indirectly linked to careers in web technologies?
    10·1 answer
  • What would a digitizing application create?
    13·2 answers
  • The purpose of a good web page design is to make it
    9·2 answers
  • Tina has taken the time to modify font sizes and colors in a text box and would like to duplicate those settings on other text b
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!