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
klemol [59]
3 years ago
9

9.10: Reverse ArrayWrite a function that accepts an int array and the array ’s size as arguments . The function should create a

copy of the array , except that the element values should be reversed in the copy. The function should return a pointer to the new array . Demonstrate the function by using it in a main program that reads an integer N (that is not more than 50) from standard input and then reads N integers from a file named data into an array . The program then passes the array to the your reverse array function, and prints the values of the new reversed array on standard output , one value per line. You may assume that the file data has at least N values .Prompts And Output Labels. There are no prompts for the integer and no labels for the reversed array that is printed out.Input Validation. If the integer read in from standard input exceeds 50 or is less than 0 the program terminates silently.The Language is C++
Computers and Technology
1 answer:
AleksandrR [38]3 years ago
8 0

Answer:

#include <iostream>

using namespace std;

int * reverse(int a[],int n)//function to reverse the array.

{

   int i;

   for(i=0;i<n/2;i++)

   {

       int temp=a[i];

       a[i]=a[n-i-1];

       a[n-i-1]=temp;

   }

   return a;//return pointer to the array.

}

int main() {

   int array[50],* arr,N;//declaring three variables.

   cin>>N;//taking input of size..

   if(N>50||N<0)//if size greater than 50 or less than 0 then terminating the program..

   return 0;

   for(int i=0;i<N;i++)

   {

       cin>>array[i];//prompting array elements..

   }

   arr=reverse(array,N);//function call.

   for(int i=0;i<N;i++)

   cout<<arr[i]<<endl;//printing reversed array..

   cout<<endl;

return 0;

}

Output:-

5

4 5 6 7 8

8

7

6

5

4

Explanation:

I have created a function reverse which reverses the array and returns pointer to an array.I have also considered edge cases where the function terminates if the value of the N(size) is greater than 50 or less than 0.

You might be interested in
1) List at least five smaller behaviors you could break the complex behavior "brushing my teeth" into.
zhuklara [117]
Q1:
1. Go into the bathroom
2. Put toothpaste on the toothbrush
3. Place head of toothbrush on your teeth
4. Revolve in small circles
5. Repeat 4 for all of your teeth
6. Use water to wash away the toothpaste in you mouth
5 0
2 years ago
Read 2 more answers
Why does my laptop keep disconnecting from the wifi.
poizon [28]

Answer: you may be connected to wifi near you

Explanation:

1. Restart your computer

2 Then got to settings

3 Go to Wi-Fi

4. Disconnect from your Wi-Fi

5 Connect to your Wi-Fi

If that does not work, go look it up lol.

3 0
2 years ago
Ivy is a student. She is looking for some freelance assignments during her vacation. Which of the following networking sites can
lara [203]

The answer is D. XING


3 0
3 years ago
2 what is deep learning?
lozanna [386]

Answer:

a type of machine learning based on artificial neural networks in which multiple layers of processing are used to extract progressively higher level features from data.

5 0
1 year ago
With ____ editing, Word automatically displays a Paste Options button near the pasted or moved text.
harina [27]
The answer is drag and drop. 
 With drag and drop editing, word automatically displays a paste option button near the pasted or moved text. 
8 0
3 years ago
Other questions:
  • The first character of the VIN designates which of the following? 
    15·2 answers
  • When reading data across the network (i.e. from a URL) in Python 3, what string method must be used to convert it to the interna
    9·1 answer
  • Int a=10 int b=20<br> A=b<br> The new values for a and b are
    11·2 answers
  • All linear programming problems have all of the following properties EXCEPT
    9·2 answers
  • - Explain the Windows User Authentication process for Client connecting to the domain
    11·1 answer
  • Retraining is required at intervals of ___ or less.
    10·1 answer
  • What is an information technology? ​
    12·2 answers
  • Please choose odd one out please tell fast ​
    13·2 answers
  • A debate about city schools are more better than village schools​
    8·1 answer
  • Ups developed software called ____ to enable u.s. customs and border protection agents to inspect packages that pass through the
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!