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
Name of the best Android keyboard
mrs_skeptik [129]

I think Gboard is good, you can switch between languages quickly and you can translate in real time. Translation is not perfect, but it is the best translation available. Vocabulary and autocorrect is not bad too. You can change the background. It has some themes of its own, but you can always customise it with your own photo. It has instant gif, stickers and emoji options too. It also has a good collection of symbolic emojis like: *\0/*O_o(๑♡⌓♡๑)ᕙ( • ‿ • )ᕗ(☉。☉)!I cannot include all of them, they are in 100s.

But if you are looking for a solution for grammatical mistakes, then you may want to consider Grammarly.

5 0
3 years ago
(display five messages) write a program that displays welcome to java five times.
Nitella [24]
<span>/** * * * Exercise 1.2 - Display Five Messages * */ public class Ex01_02 { public static void main(String[] args) { System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); System.out.println("Welcome to Java"); } }</span>
4 0
3 years ago
What determines the speed st which your computer perfoms tasks?
tamaranim1 [39]

The central processing unit (CPU) is what powers the computer. Any lower-end CPUs will not run a quick-functioning computer very well.

3 0
4 years ago
Which of the following is NOT one of the most important elements when designing a website?
Dmitriy789 [7]
Screen resulution Hope this helps
7 0
3 years ago
Read 2 more answers
¿Qué es el Internet? ¿Cuál es el protocolo de Internet?
mina [271]

Answer:

El Protocolo de Internet (IP) es el principal protocolo de comunicaciones en el conjunto de protocolos de Internet para transmitir datagramas a través de los límites de la red. Su función de enrutamiento permite la interconexión de redes y esencialmente establece Internet. ... Por lo tanto, el conjunto de protocolos de Internet a menudo se denomina TCP / IP.

Explanation:

4 0
3 years ago
Other questions:
  • In "Brer Rabbit Gets Brer Fox's Dinner," what is Brer Fox busy doing?
    10·2 answers
  • Chunking is a good strategy for completing large assignments because it makes the work
    7·2 answers
  • Which of the following actions has no impact on your credit score
    9·1 answer
  • Can someone please answer these questions! Thank you :)
    5·1 answer
  • Create an application named StudentsStanding.java that allows you to enter student data that consists of an ID number, first nam
    12·1 answer
  • What precautions should be taken to make a computer more secure ​
    8·1 answer
  • The Table Design and Layout tabs are available under the
    13·2 answers
  • Who addicted to fnaf
    5·2 answers
  • 10. Site-to-Site VPN architecture is also known as
    6·1 answer
  • ASAP PLS I DON T HAVE ENOUGH TIME
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!