answer.
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]
1 year 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]1 year 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
Write a SQL query to find the population of the planet named 'Caprica' -- 10 points Find the first name, last name, and age of p
Artemon [7]

The question is incomplete! Complete question along with answer and step by step explanation is provided below.

Please find the attached question.

Answer:

a) SQL Query:

SELECT population

FROM bsg_planets

WHERE name='Caprica';

b) SQL Query:

SELECT fname, lname, age

FROM bsg_people

WHERE lname!='Adama';

c) SQL Query:

SELECT name, population

FROM bsg_planets

WHERE population > 2600000000

d) SQL Query:

SELECT fname, lname, age

FROM bsg_people

WHERE age IS NULL;

Explanation:

a) Write a SQL query to find the population of the planet named 'Caprica'

Syntax:

SELECT  Column

FROM TableName

WHERE Condition;

For the given case,

Column = population

TableName  = bsg_planets

Condition = name='Caprica'

SQL Query:

SELECT population

FROM bsg_planets

WHERE name='Caprica';

Therefore, the above SQL query finds the population of the planet named 'Caprica' from the table bsg_planets.

b) Find the first name, last name, and age of people from bsg_people whose last name is not 'Adama'

Syntax:

SELECT  Column1, Column2, Column3

FROM TableName

WHERE Condition;

For the given case,

Column1 = fname

Column2 = lname

Column3 = age

TableName  = bsg_people

Condition = lname!='Adama'

SQL Query:

SELECT fname, lname, age

FROM bsg_people

WHERE lname!='Adama';

Therefore, the above SQL query finds the first name, last name and age of people whose last name is not 'Adama' from the table bsg_people.

c) Find the name and population of the planets with a population larger than 2,600,000,000

Syntax:

SELECT  Column1, Column2

FROM TableName

WHERE Condition;

For the given case,

Column1 = name

Column2 = population

TableName  = bsg_planets

Condition = population > 2600000000

SQL Query:

SELECT name, population

FROM bsg_planets

WHERE population > 2600000000

Therefore, the above SQL query finds the name and population of the planets with a population larger than 2,600,000,000 from the table bsg_planets.

d) Find the first name, last name, and age of people from bsg_people whose age is NULL

Syntax:

SELECT  Column1, Column2, Column3

FROM TableName

WHERE Condition;

For the given case,

Column1 = fname

Column2 = lname

Column3 = age

TableName  = bsg_people

Condition = age IS NULL

SQL Query:

SELECT fname, lname, age

FROM bsg_people

WHERE age IS NULL;

Therefore, the above SQL query finds the first name, last name and age of people whose age is NULL from the table bsg_people.

6 0
2 years ago
Read 2 more answers
Please help!! Caleb is working on a simple logic-based program to simulate a game of tic-tac-toe. Which programming language wou
irga5000 [103]

Basic language should do it

4 0
2 years ago
Write any 5 activities that help to remove bad events from the society?​
vova2212 [387]

Answer:

1. Awareness program

2. Education

3. women empowerment

6 0
1 year ago
Read 2 more answers
A patient asks her doctor to send a copy of her records to another medical office. However, the records are not transmitted beca
bezimeni [28]
 This type of security failure is called WIN32K_SECURITY_FAILURE. <span> This indicates a </span>security failure was detected in win32k. <span>According to a new report issued by Dark Reading, there are a number of key </span>security failures<span> that cybercriminals take advantage of.</span>
5 0
2 years ago
Read 2 more answers
At an open or uncontrolled intersection, yield if ____.
inn [45]

Answer: A. The cross road has more lanes than yours

8 0
2 years ago
Read 2 more answers
Other questions:
  • In a situation where handicapped person can only input data into the computer using a stylus or light pen, which keyboard config
    7·2 answers
  • What is a typical grace period for a credit card...
    15·2 answers
  • Software code is tested, debugged, fixed, verified, and then:
    11·1 answer
  • Write a program that allows you to create a file of customers for a company. The first part of the program should create an empt
    12·1 answer
  • Assign decoded_tweet with user_tweet, replacing any occurrence of 'TTYL' with 'talk to you later'. Sample output with input: 'Go
    14·2 answers
  • Which of the following provides a suite of integrated software modules for finance and accounting, human resources, manufacturin
    15·1 answer
  • 8.Change the following IP addresses from binary notation to dotted-decimal notation: a.01111111 11110000 01100111 01111101 b.101
    10·1 answer
  • When do images or graphics in Microsoft Word hurt the document rather than help
    9·1 answer
  • All organizations need good quality cybersecurity to ensure _____. Select 4 options.
    12·2 answers
  • # 1) Complete the function to return the result of the conversion
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!