9.11: Array Expander
Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is twice the size of the argument array. The function should copy the contents of the argument array to the new array, and initialize the unused elements of the second array with 0. 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 your array expander function, and prints the values of the new expanded 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.

Answers

Answer 1

The Array Expander is an illustration of arrays and functions.

Arrays are variables that stores multiple valuesFunctions are named statements that are executed when called

The Array Expander program

The Array Expander program written in C++, where comments are used to explain each action is as follows:

#include <iostream>

using namespace std;

//This declares the Array Expander function

int* ArrayExpander(int *oldArr, int size){

   //This declares the new array

   int *newArr = new int[size * 2];

//This iteration sets values into the new array

   for (int i = 0; i < size * 2; i++) {

       if(i < size){

           *(newArr+i) = *(oldArr+i);

       }

       else{

           *(newArr+i) = 0;

       }

   }

//This returns a pointer to the new array

   return newArr;

}

//The main method begins here

int main(){

//This declares the length of the array, N

   int N;    

//This gets input for N

   cin>>N;

   int initArr[N];

//If N is between 1 and 50

   if(N > 0 && N <=50){

//This iteration gets values for the array

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

           cin>>initArr[i];

       }

//This calls the Array Expander function

   int *ptr = ArrayExpander(initArr, N);

//This iteration prints the elements of the new array

   for (int i = 0; i < N*2; i++) {

       cout << ptr[i] << " ";

   }

   }

  return 0;

}

Read more abou C++ programs at:

https://brainly.com/question/27246607


Related Questions

Difference between centralized and decentralized processing in computer

Answers

Answer:

Centralized computing is analogous to star topology in the networks where there is n entry and n-1 exit points. We see all the computation being carried out by the pivot processor and also embed in itself a decision routine for pass on the message to other linked systems. These systems are merely the mirror whereas the computing is done by the pivot processor.

Decentralized Computing is analogous to distributed node based processing where the topology for interaction among the nodes are random and hence some times there is delay because of the orientation of nodes by since the computation is disperse, it compensates in the time in processing, storage and retrieval.

You can definitely check into IBM and Amazon Research for examples for the Centralized and Decentralized computing.

What command allows the root user to create a crontab file for the user jdoe?

Answers

The command allows the root user to create a crontab file for the user jdoe is As root, execute crontab -e jdoe.

What is the command in crontab?

The crontab command is known to be that often submits, make some editing, lists, or delete cron jobs.

Note that A cron job is a type of command that is often aided or  run by the cron daemon at  a consistent and scheduled times.

Conclusively, The  As root, execute crontab -e jdoe command will give room for the root user to create a crontab file for the user named jdoe.

Learn more about command form

https://brainly.com/question/25243683

How many bytes can be stored in a 4gb flash drive

Answers

Answer:

4,294,967,296; theoretically

Explanation:

There is 1024 bytes in a kb, 1024 kb in a mb, 1024 mb in a gb.

So we can use 1024³ as a multiplier to convert gb->byte.

1024³ * 4 = 4,294,967,296 bytes.

However, in practice hardrives always have less useable storage than the quoted amount.

Strategies of Green computing include:

Answers

Answer:

Equipment recycling, reduction of paper usage, virtualisation, cloud computing, power

The major goal of a good web information
a
retrieval system is

Answers

Answer:

Explanation:

The major objective of an information retrieval system is to retrieve the information – either the actual information or the documents containing the information – that fully or partially match the user's query.

what is the name of the extension used to save publisher

Answers

Answer:

PUB

Explanation:

PUB IS THE NAME OF THE EXTENSION USED TO SAVE PUBLISHER

Luke is working on a layout for a catalog. He adds cross lines on the four corners of the layout to mark out a small extra margin. What are these lines called?
A.
edge
B.
dark
C.
index
D.
trim

Answers

Cross lines that are added on the four corners of a layout to mark out a small extra margin is called: D. trim.

What is layout design?

Layout design can be defined as a graphical design process that involves the use of one or more grids for the design of a catalog and system, so as to make the designs visually appealing to end users.

In a layout design, trim refers to the cross lines that are added on the four (4) corners of a layout to mark out a small extra margin.

Read more on layout design here: https://brainly.com/question/13732745

17) If you want to find the average salary (with each employee's salary found in column C) for those who are full time employees (which will have "FT" in column B), you would use the ________ function.

A. COUNTAVERAGE


B. IFAVERAGE


C. AVERAGE


D. AVERAGEIF

Answers

Answer:

AVERAGE

Explanation:

THIS is a function used in Microsoft Excel.

The steps to find average is

Sum/Total

Hence

first we use AUtoSUM function to find sum then we use average to calculate

Answer:

Average

Explanation:

If you want to find the average salary (with each employee's salary found in column C) for those who are full time employees (which will have "FT" in column B), you would use the AVERAGE function.

What is information computer security

Answers

Answer:

Computer security, cybersecurity, or information technology security is the protection of computer systems and networks from information disclosure, theft of or damage to their hardware, software, or electronic data, as well as from the disruption or misdirection of the services they provide.

Explanation:

1.Skills

1.SkillsThe Top Skills Required for Cybersecurity Jobs

1.SkillsThe Top Skills Required for Cybersecurity JobsProblem-Solving Skills. ...

1.SkillsThe Top Skills Required for Cybersecurity JobsProblem-Solving Skills. ...Technical Aptitude. ...

1.SkillsThe Top Skills Required for Cybersecurity JobsProblem-Solving Skills. ...Technical Aptitude. ...Knowledge of Security Across Various Platforms. ...

1.SkillsThe Top Skills Required for Cybersecurity JobsProblem-Solving Skills. ...Technical Aptitude. ...Knowledge of Security Across Various Platforms. ...Attention to Detail. ...

1.SkillsThe Top Skills Required for Cybersecurity JobsProblem-Solving Skills. ...Technical Aptitude. ...Knowledge of Security Across Various Platforms. ...Attention to Detail. ...Communication Skills. ...

1.SkillsThe Top Skills Required for Cybersecurity JobsProblem-Solving Skills. ...Technical Aptitude. ...Knowledge of Security Across Various Platforms. ...Attention to Detail. ...Communication Skills. ...Fundamental Computer Forensics Skills. ...

1.SkillsThe Top Skills Required for Cybersecurity JobsProblem-Solving Skills. ...Technical Aptitude. ...Knowledge of Security Across Various Platforms. ...Attention to Detail. ...Communication Skills. ...Fundamental Computer Forensics Skills. ...A Desire to Learn. ...

1.SkillsThe Top Skills Required for Cybersecurity JobsProblem-Solving Skills. ...Technical Aptitude. ...Knowledge of Security Across Various Platforms. ...Attention to Detail. ...Communication Skills. ...Fundamental Computer Forensics Skills. ...A Desire to Learn. ...An Understanding of Hacking

2.Thesaurus

ThesaurusCybersecurity refers to the practice of securing electronic devices from unauthorized access or attack or the measures taken in pursuit of this practice.

3.Risk assessment

Risk assessmentWhat does a cybersecurity risk assessment include? A cybersecurity risk assessment identifies the various information assets that could be affected by a cyber attack (such as hardware, systems, laptops, customer data, and intellectual property), and then identifies the various risks that could affect those assets.

and last..........is four

4. Field

FieldDifferent branches of cyber security

FieldDifferent branches of cyber securityApplication security.

FieldDifferent branches of cyber securityApplication security.Network and infrastructure security.

FieldDifferent branches of cyber securityApplication security.Network and infrastructure security.Intrusion detection and penetration testing.

FieldDifferent branches of cyber securityApplication security.Network and infrastructure security.Intrusion detection and penetration testing.Digital forensics and incident response.

FieldDifferent branches of cyber securityApplication security.Network and infrastructure security.Intrusion detection and penetration testing.Digital forensics and incident response.Endpoint protection and mobile security.

FieldDifferent branches of cyber securityApplication security.Network and infrastructure security.Intrusion detection and penetration testing.Digital forensics and incident response.Endpoint protection and mobile security.Data governance, risk and compliance.

What are the major benefits of preproduction?

Answers

Some of the benefits of preproduction are that it:

Saves time while producingKeeps you on a BudgetYou could have more time to think about how you are going to produce your production.

Hope this could help?

What command is used to list at jobs that are scheduled for execution?

Answers

The command that is used to list at jobs that are scheduled for execution is The at command.

What is the at command?

This is known to be a kind of  a Linux command-line utility. It function mainly to book down a job for future execution.

Conclusively. This kind of utility is one that reads commands from standard input and them bind them together into an at job, which can only be executes only once at a time.

Learn more about command  from

https://brainly.com/question/25808182

What should I do instead of listen to music?

Answers

You could watch a movie
Learn something new that you are interested in

Explain the main concept of Artificial Neural networks (ANN) as a set of layers that starts with an input layer that has sensors and the output layer that gives the predicted result (predictions) with hidden layers in between based on the ANN architecture and its specific type of application Knowledge One Individual Practical Assignment

Answers

Artificial Neural networks is a computational tool that is made up of a let of processing elements that takes in inputs and deliver outputs using a predefined activation codes.

What are the layers in an artificial neural network?

There are 3 Artificial olfactory sense and recognition system that are found in ANN.  It is made up of:

An input layer.An Hidden layer.An Output layer.

Note that these layers above help to tell more about the Artificial Neural networks (ANN).

Learn more about  Artificial Neural networks (ANN) from

https://brainly.com/question/25653113

Ncomputing and thin client
what it is
why is done , how it works and how it's
done ​

Answers

The term NComputing  is known to be a form of desktop virtualization company that is said to creates hardware and software to form virtual desktops.

The term Thin clients is known to be virtual desktops. They help a lot of users at the same time to share a single operating system instance.

What is the aim of a thin client?

In Ncomputer networking, a thin client is known to be a kind of low-performance computer that is known to be optimized and used for setting up a remote connection.

It is often used with a server-based computing system. The server here is one that often does most of the work, such as launching software programs, etc.

Learn more about Ncomputing from

https://brainly.com/question/12629145

9.12: Element Shifter
Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is one element larger than the argument array. The first element of the new array should be set to 0. Element 0 of the argument array should be copied to element 1 of the new array, element 1 of the argument array should be copied to element 2 of the new array, and so forth. 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 your element shifter function, and prints the values of the new expanded and shifted 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.

Answers

The Element shifter program illustrates the use of functions and arrays

Arrays are used to hold multiple valuesFunctions are used as subroutines of a program

The Element shifter program

The Element shifter program written in C++, where comments are used to explain each action is as follows:

#include <iostream>

using namespace std;

//This declares the ElementShifter function

int* ElementShifter(int *arr, int size){

   //This declares the new array

   int *newArr = new int[size * 2];

//The following loop populates the new array

   for (int i = 0; i < size * 2; i++) {

       if(i == 0){

           *(newArr+i) = 0;

       }

       else if(i < size+1){

           *(newArr+i) = *(arr+i-1);

       }

       else{

           *(newArr+i) = 0;

       }

   }

//This returns a pointer to the new array

   return newArr;

}

//The main method begins here

int main(){

//This declares and gets input for N

   int N;    cin>>N;

   int myArr[N];

//If N is between 1 and 50

   if(N > 0 && N <=50){

//This populates the array

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

           cin>>myArr[i];

       }

//This calls the Element shifter function

   int *ptr = ElementShifter(myArr, N);

//This prints the new array

   for (int i = 0; i < N*2; i++) {

       cout << ptr[i] << " ";

   }

   }

  return 0;

}

Read more abou C++ programs at:

https://brainly.com/question/27246607

Name three things that get information into a computer?​

Answers

Answer:

Input devices do that. Three are the keyboard, a mouse, and a trackball.

Explanation:

What is Word's default color for highlighting text?
O orange
O gray
O yellow
O blue

Answers

Answer:

Yellow.

Explanation:

Yellow is typically the color but you can always manually change it.

Answer:

yellow

Explanation:

On the home tab of the ribbon the default color for highlighting text and tool is yellow

what seemingly useless item can be of social, ecological or commercial value?

Answers

Earrings. They do nothing practical, but they provide social value by making you look more attractive.

Some seemingly useless item can be of social, ecological or commercial value is money, behavior, death etc.

What is something really useless?

A useless item are known to be things that are said to be rubbish.

They are items that is useless, of no value. Some  useless item can be of social, ecological or commercial value is money, behavior, vehicles etc.

Learn more about commercial value from

https://brainly.com/question/25528419

The algorithm solves the problem
of size n by recursively solving
sub-problems of size n – 1, and
then combining the solutions in
Q(n) time.

Answers

Looking at the question on algorithm above, the correct answer is: [tex]O( {2}^{n} )[/tex]

What is algorithm?

Algorithm refers to a sequence of instructions that have been well-defined which helps to solve specific problems. Algorithm is used in computation.

The recurrence relation is:

T(n)=2.T(n-1)+c , n>0

T(n)=1, n=0.

Considering the back substitution method,

T(n) = 2kT(n-k)+ 2k-1c+....+20c

Substitute n-k=0

Therefore, we will have:

T(n) = 2nT(0)+ 2k-1c+....+20c

T(n) = [tex] {2}^{n - 1} + 1[/tex]

T(n) = [tex]O( {2}^{n} )[/tex]

Learn more about algorithm on https://brainly.com/question/24953880

which of the following is an example of application software

Answers

Answer:

A messaging app

Explanation:

Its an software application you can download, so...yeah.

(You might've thought it was an anti-virus program lol)

Option-D.A messaging app is the correct answer.
A messaging app is an application software that can be installed jn your phone and computer in order to send messages.

What is an Application software?Application software is a type of computer application that performs specific professional, academic, and individualized functions.Each software is designed to assist users with a variety of tasks, some of which may be related to productivity, creativity, or communication.Word processors, media players, and accounting software are examples of application programs.An application program (also known as a software application, application, or app for short) is a computer program created to carry out a specific task other than one related to the operation of the computer itself.The term "app" typically refers to apps for mobile devices such phones. Applications may be published independently or packaged with the computer and its operating system software.They may also be written in proprietary, open-source, or project code.An application can work with text, numbers, audio, visuals, and a combination of these depending on the task for which it was created.Word processing is an example of an application package that focuses on a particular task.On the other hand, integrated software merges several programs.

To learn about the DIfference between application software and Opertaing system click here-
https://brainly.com/question/17798901

#SPJ2

How many categories of computer do we have?

Answers

Answer:

The 10 types of computers include personal computers, desktops, laptops, tablets, hand-held computers, servers, workstations, mainframes, wearable computers and supercomputers.

display unit is capable of displaying test but not ​

Answers

Answer:

I think your question must be display unit is capable of displaying text but not.

Explanation:

A text display is an electronic alphanumeric display device that is mainly or only capable of showing text, or extremely limited graphic characters.

Name the test statement that can be used to test the following scenario:
The contents of the variable $TEST are equal to the string “success,” or the number 5, or the contents of the variable $RESULT.

Answers

The test statement is an illustration of conditional statements and logical operators.

The test statement is: if [[ "$TEST" == ”success” || "$TEST" == ”5” || "$TEST" == “$RESULT” ]]

How to name the test statement?

From the question, we have the following scenarios:

Determine if $TEST equals "success"Or $TEST equals "5"Or $TEST equals $RESULT

To do this, we make use of the if conditional statement and the or logical operator.

The or operator is represented with ||

Since the programming language is in php, the test statement is: if [[ "$TEST" == ”success” || "$TEST" == ”5” || "$TEST" == “$RESULT” ]]

Read more about conditional statements at:

https://brainly.com/question/24833629

A person entering the field of financial analysis
will end up taking what kind of classes in
college?
A. accounting
B. agriculture
C. astronomy
D. advertising

Answers

Answer:accounting

Explanation:

Difference between single dimensional array and double dimensional array​

Answers

A one-dimensional array keeps track of a single list of elements with the same data type. An array of various arrays, a list of multiple lists, or an array of numerous one-dimensional arrays are all stored in a two-dimensional array. It is a list that represents several data pieces.

ICT4AD was meant to modernize the civil service through E-governance implementation.

Explain why you believe that this policy has achieved or not achieved this goal?

Answers

ICT4AD work through E-governance implementation fail as a result of:

Lack of Infrastructure. High cost of running its affairs as it needs  huge public expenditure. Issues with Privacy and Security and others.

What is the aim of e-governance?

The objectives of e-Governance is created so as to lower the level of corruption in the government and to make sure of  fast administration of services and information.

Conclusively, It is known to fail due to the reasons given above and if they are worked on, the service would have prospered.

Learn more about civil service from

https://brainly.com/question/605499



Computer A uses Stop and Wait ARQ to send packets to computer B. If the distance between A and B is 40000 km, the packet size is 5000 bytes and the
bandwidth is 10Mbps. Assume that the propagation speed is 2.4x108m/s
a) How long does it take computer A to receive acknowledgment for a packet?
b) How long does it take for computer A to send out a packet?

Answers

The time that it takes the computer to receive acknowledgment for a packet is 0.1667 seconds. The time it takes to send out a packet is  4 x 10⁻³seconds

1 The acknowledgment time for the packet

speed =  2.4x108m/s

Distance = 40000 km,

Time = distance/ speed

= 40000 x10³/ 2.4x10⁸m/s

= 0.1667

The time that it take is 0.1667 seconds.

b. Number of bytes = 5000

5000x 8 = 40000bits

10 mbps = 10000 kbps

10000 kbps = 10000000

packet size / bit rate = 40000/10000000

= 4 x 10⁻³seconds to send a packet out

Read more on computer bandwith here: https://brainly.com/question/27020560

list the factors that influenced the advancement of AI in recent years​

Answers

Answer:

In any case, there are 5 factors which are driving the development of Artificial Intelligent and other technologies of Big Data, ML, etc.

Next-Generation Computing Architecture. ...

Open Data. ...

Growth in Deep Neural Networks. ...

Legal and Ethical Issues. ...

Historical Datasets.

How does a workstation differ from a server in terms of price processing power storage and computer memory

Answers

Workstations are laptops and PCs that quickly perform complex, technical tasks such as digital content creation and detailed analysis. Servers are software and hardware that store data, manage network resources, and fulfill client requests.

9) Which date is assigned the serial number of 1?


A. January 1, 1700


B. January 1, 2000


C. January 1, 1900


D. January 1, 1800

Answers

Answer:

c) January 1, 1900

Explanation:

January 1, 1900 (1 - 1 - 1900) is assigned the serial number of 1. The serial number 1 represents January 1, 1900. Hence, option (c) is the correct answer.

Other Questions
The triangle on the right is a scaled copy of the triangle on the left. Identify the scalefactor. Express your answer as a whole number or fraction in simplest form.515/215/2 Hi I new to brainly what dose paws off mean??? Hope's contribution to her RETIREMENT plan...a. is a post-tax contribution on which she pays federal income taxesb. is pre-tax and therefore not included in federal income taxesc. Is a contribution to her Social Securityd. is taxed at a rate of 15% Why do Hindu people create Rangoli during festivals and holidays? (4 points) a To bring good luck b To bring good weather c To represent love d To represent the universe Mario has debt on two credit cards, a private student loan, a Federal student loan, and a car loan. His priority is to eliminate some of these debts entirely by the end of the year. Which payoff strategy -- debt snowball or high rate - - do you recommend? Why? Eastlands government has a total national debt of $500 million, which is financed as follows: $100 million is held by other government agencies, $200 million is held by Eastlands citizens, and $200 million is held by foreign citizens. The amount of public debt in Eastland is:$500 million.$400 million.$300 million.$100 million. Andre set up a lemonade stand last weekend. It cost him $0.15 to make each cup of lemonade, and he sold each cup for $0.35.If Andre collects $9.80, how many cups did he sell?How much money did it cost Andre to make this amount of lemonade?How much money did Andre make in profit This table gives a few (x,y)(x,y)left parenthesis, x, comma, y, right parenthesis pairs of a line in the coordinate plane.xxx yyy-9494minus, 94 242424-7474minus, 74 181818-5454minus, 54 121212What is the xxx-intercept of the line?((left parenthesis,,comma)) All real estate advertising (use of business stationary, newsletters, billboards, etc.) must be done only with the ____________ knowledge and consent. in the march book one john Lewis In a couple of sentences, describe early efforts at sit-ins and their outcome. An analysis of theme in pop criticism would most likely fall under which criteria?O aestheticsO authenticityO subject mattero universality Complete the reasons for the proof.given:m 3 = m 4Prove 1 and 2 are supplementary The opening graph in the video shows the measured relative abundances of elements in the galaxy. What is the 4th most abundant element?. Question 7 of 10Read this scenario:A small child wanders away from his home. His motherruns through the town shouting his name. Neighbors rushout of their homes and begin searching with her. Finally, agroup of men mount their horses and head into the darkforest. After a long night of searching, the men return withthe child.What would a culture that tells this story most likely value? David poole linear algebra 4th edition solutions pdf 2. In 1924, the price of a Ford ModelTwas only $260. Today the priceof the least expensive automobilein America is many times that sum.There were more automobile firms inbusiness in 1924 than there are today.Does the higher price of cars resultchiefly from the reduction of firmsand the resulting loss of competition? REVISE: It was raining. (Use sight and sound details) What is the goal of an SSP? 17,18,22,31,47, ... what's next 5 chocolate bars cost $5.75 2 chocolate bars and 3 packets of sweets cost $7.85 work out the cost of one packet of sweets