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
A virtual meeting is the same thing as a/an A. online meeting. B. VoIP. C. seminar. D. convention.
Kryger [21]
I believe it's A. online meeting
5 0
3 years ago
What is an example of using the internet of things (iot) to deliver innovative cloud-based solutions to customers?
Elina [12.6K]

Answer:

Wearable technology

Explanation:

An example of using the Internet of Things (IoT) to deliver innovative cloud-based solutions to customers is the wearable technology that provides customers with on-the-spot personalized experiences.

4 0
2 years ago
Hawaii and japan are examples of islands made by? You have to write it.
Brums [2.3K]

Answer:

Volcanic activity

5 0
3 years ago
What can be used to help diagnose and fix computer hardware problems?
Klio2033 [76]

the answer is D which is system utilities

hope this helps and hope it isn't wrong

8 0
2 years ago
Write a python coding to input ten random numerical vales to a list. And display the list. Use a loop structure to enter values.
Zarrin [17]

Answer:

000110011111000010010101001001

Explanation:

8 0
3 years ago
Other questions:
  • QUESTION : John travels a lot and he needs to access his documents and services on the go. Which of these technologies allows hi
    15·1 answer
  • Deon is required to provide the citation information for his sources. What type of information should he collect from his source
    10·2 answers
  • Which tab is used to edit objects on the slide master and layouts
    10·1 answer
  • This program outputs a downwards facing arrow composed of a rectangle and a right triangle. The arrow dimensions are defined by
    11·1 answer
  • Using the world_x database you installed in Module 1, list the countries and the capitals of each country. Modify your query to
    11·1 answer
  • What does ADAC mean <br> pls answer quickly i will mrk brainliest
    14·2 answers
  • Does technology shape society or does society shape technology?
    14·1 answer
  • Anyone help me please​
    6·2 answers
  • Ethan is a project manager who is responsible for overseeing overall budget and schedule. Which tool is he is MOST likely to use
    7·1 answer
  • Intro Programming - Problem(s)
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!