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
Which computer applications can Mr. Crowell use to make the classroom learning more stimulating and interesting? Mr. Crowell has
katovenus [111]

Answer:

He can use following computer program to make the class room more interesting and effective:-

  • 1. <u>Reference software</u> : This software help students to access the atlases and dictionaries.Teacher can include this software in research projects .

  • 2. <u>Educational Games</u>: This types of software is very effective for younger children because it motivates them to learn.This software companies have combined gaming and education into one .

  • 3. <u>Graphical software</u> : Student can use this software to create and changes images available on the internet itselfs .
4 0
2 years ago
Read 2 more answers
There are many careers within the IT industry. _____ are responsible for organizing a company's data, making sure all the data i
devlian [24]
C. database administrators are responsible for organizing a company's data making sure all the data is accurate' available' and secure
5 0
2 years ago
Identify tags and attributes in HTML 5
Vaselesa [24]

Answer:

Tags can be identified as they are written as <tagname> Something </tagname>

<tagname> this tag is called start tag.

</tagname> this tag is called as end tag.

for ex:<p> This is a paragraph </p>

There are some elements with no end tag.for ex:- <br> tag.

Attributes are used to provide additional information to an HTML element.

Every element can have attributes.

for Ex:- <h1 style="background-color:red";>MY WEBSITE </h1>

So the background of h1 will become red.

7 0
2 years ago
Rubbing two sticks together to make a fire is an example what
Jet001 [13]
Rubbing two sticks together will cause friction
7 0
3 years ago
Read 2 more answers
A series of dialog boxes that guides you through creation of a form or report is called a ____.
victus00 [196]

Answer:

c i think it mit be right i'm sorry if it's not ,

Explanation:

it's c or D.

4 0
2 years ago
Other questions:
  • ¿Cuál es el objetivo principal de los servicios?
    7·1 answer
  • People in STEM careers are considered thinkers who reach conclusions through sound judgment and reasoning.
    11·1 answer
  • A U.S. social security number consists of a string of 9 digits, such as "444422333". Declare a char array named ssn suitable for
    5·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    11·2 answers
  • If I could make a Short Film on any topic it would be...how could that film change the world?
    9·1 answer
  • Sometimes we care about the order of a list, and need to reorder the items according to a condition (alphabetical, numerical, et
    11·2 answers
  • Example of language processor software
    8·1 answer
  • Need help ASAP.<br> I am so lost.
    5·1 answer
  • A web-based program that uses artificial intelligence techniques to automate tasks such as searches is called
    8·1 answer
  • Please help……Your friend is taking images from all over the internet without giving credit to the sources. He tells you that it’
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!