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
How do you put text in MS publisher?<br><br> When do you use text wrapping?
coldgirl [10]
First question: On the Format tab, in the Arrange group, click Wrap Text. Do one of the following: Click Square to wrap text around the border of your image. Click Tight to wrap text closely around an irregularly shaped picture.


Second question: you use text wrapping when you want to surround a picture or diagram with text.

Hope this helps!
7 0
3 years ago
Standards for all managers ethical responsibilities are covered in a company's
attashe74 [19]
C. Code of ethics is correct.
4 0
3 years ago
Read 2 more answers
What are the 6 external parts of a computer system
denis23 [38]
1. Monitor
2.C.P.U
3.Mouse
4. Keyboard
5. Printer
6. Speaker
4 0
3 years ago
When talking about careers in designing game art, the unit mentioned that a good portfolio and a clear record of experience in g
atroni [7]

Answer:

Explanation:

Many different answerd to this

I dont know what course your taking exactly but i'll do my best <3

Personnally im most interested in balancing in game rewards, balancing AI, or balancing in game currency.

Hmm... I dont really kno what you could add to your portfolio tho. Maybe some things you did that involve what youre interested in doing.

Hope this helps <3

8 0
3 years ago
State the difference between a monitor and a television​
Maurinko [17]
The size of a monitor is not much larger. As these are used from a specific distance, it would be so inconvenient if a monitor size is too big.
7 0
2 years ago
Read 2 more answers
Other questions:
  • Write a program that reads a list of words. Then, the program outputs those words and their frequencies. The input begins with a
    13·1 answer
  • Swiping up with three fingers on mac os x launches what?
    8·1 answer
  • Which tasks can be completed using the Chart Tools Design tab? Check all that apply.
    9·1 answer
  • Consider the following code snippet:
    13·1 answer
  • Select three physical forms of storage. USB drive Primary cache Magnetic storage Secondary cache Dynamic RAM Optical drive
    7·2 answers
  • What time is it NOW??
    11·2 answers
  • 3.5 code practice question 1
    5·2 answers
  • 1. You are given a database to create, however, you realize that in the instructions you are told to create relationships betwee
    5·1 answer
  • Pls need this asap
    14·2 answers
  • The equals method of the Object class returns true only if the two objects being compared:_________
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!