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

Answer 1

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


Related Questions

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

Explain why database management systems are used in hospitals? Discuss

Answers

The reason why database management systems are used in hospitals is because the use of Healthcare databases aids in terms of diagnosis and treatment, handle documentation and billing, and others.

What is a database management system in healthcare?

A database management system (DBMS) is known to be a type of software that has been developed to help people to form and keep databases.

It is one that helps to lower the risk of errors associated with medical operations and management. It reduces  paperwork and staff and also improves  performance.

Learn more about database management from

https://brainly.com/question/24027204

How can use of the Internet potentially be a security issue?

Programs, such as spyware, are mistakenly accessed by visiting an infected
website.
Individuals called viruses attempt to secretly enter another computer to harm it.
Phishing attempts to get someone's personal data with fake emails and social
media requests.
Unwanted software called hackers can transmit personal data from a computer.

Answers

Answer:

Unwanted software called hackers can transmit personal data from a computer.

Explanation:

The other options mention "attempt" meaning it hasn't happened yet. So I'm going to assume the last one is right. I'm not 100%

A victimless crime is committed when
|. Select 3 options.
someone downloads a pirated song or video
a copyrighted image is used without permission
a stranger accesses your internet banking
a person downloads and uses pirated software
a hacker sells a company's financial statements

Answers

Someone downloads a pirated song or video a copyrighted image is used without permission and a person downloads and uses pirated software.

A victimless crime is committed when a copyrighted image is used without permission 2. a stranger accesses your internet banking 3. a hacker sells a company’s financial statements.

Victimless crimes are illegal acts that break the laws, but there is no single victim of the crime. They are against social values and laws. A copyrighted image is used without permission

Examples are gambling, traffic violations, etc. Thus, Victimless crimes differ from other types of crime because it does not have an identifiable victim. This crime is against laws and social values and beliefs.

To know more about victimless crimes, visit:

brainly.com/question/17251009

#SPJ6

what is containment and why is it part of the planning process

Answers

Answer:

Isolating affected channels, processes, services, or computers; stopping the losses; and regaining control of the affected systems. It is part of the planning process to identify the best containment option for each scenario or system affected.

Explanation:

You can always trust information that comes from websites ending in. . com

Answers

Answer:

No, Don't go there I can name more than 3 websites that end in ".com" that u cant trust.

Explanation:

Which of the following are vector graphic file formats? Choose all that apply.

AI

PNG

RAW

SVG
Please help

Answers

There are different kinds of files. The option that is a vector graphic file formats is SVG.

What are vector files?

Vector files are known to be a type of images that are created by using mathematical formulas that stands as points on a grid.

The SVG  is known as Scalable Vector Graphics file and it is known to be a  vector image file format as it make use of geometric forms such as points, lines, etc.

Learn more about vector graphic file from

https://brainly.com/question/26960102

Answer:

AI and SVG

Explanation:

learned it from a comment i give all credit to them

which is considered both an input and output device?
A) Keyboard
B) Microphone
C) Speaker
D) Touchscreen Monitor
Please hurry :3 15 points

Answers

Answer:

speaker

Explanation:

its the one that gives sounds

Answer:

The answer would be D) Touchscreen Monitor

Explanation:

A Touchscreen monitor (such as a smartphone screen) outputs information to the user, while also recieving information from the user.


Why do crawlers not use POST requests?

Answers

Answer:

Generally they do not do POST requests. This is just the current state of affairs and is not dictated anywhere, I believe. Some search engines are experimenting with crawling forms, but these are still GET requests.Explanation:

nivel 1: operadores pedir 2 números al usuario y Sumarlos, restarlos, multiplicarlo y dividirlos ​

Answers

Answer:

¿Esta pregunta no tiene ningún sentido?

Explanation:

¿que estas pidiendo?

1. What is TRUNC for Delphi
programming language?
Please explain in at least 200
words.

Answers

The Trunc function cut off a floating-point value by removing the fractional part. The Trunc  function often brings back an integer result as it is not a real function.

What is the Trunc function in Delphi?

When you look at the Delphi code, the Trunc function is known to be a fuction that reduces or cut off a real-type value and make it into an integer-type value.

Note that X is a real-type expression and so the Trunc is said to often brings back an Int64 value that is meaning the value of X approximated to zero and when the cut of value of X is not found in  the Int64 range, an EInvalidOp exception is brought up.

Learn more about programming language from

https://brainly.com/question/8151764

Text based game project 1

Answers

Answer:

What is your question?

Explanation:

20
Select the correct answer
Mike logged into a shopping website and entered his username and password, which protocol will the website use to verify his credentials?
A HTTP
B SMTP
C. СМР
D. POP3
E. LDAP

Answers

Answer:

LDAP

Explanation:

The Lightweight Directory Access Protocol (LDAP) is a vendor-neutral application protocol used to maintain distributed directory info in an organized, easy-to-query manner. That means it allows you to keep a directory of items and information about them. This allows websites to verify credentials when accessing websites.

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.

If you determine that the hard drive is experiencing excessive use but the Windows Experience Index reports that memory is the system bottleneck, which component do you upgrade first: memory or the hard drive? Why?

Answers

The reason why is it is good to use an Upgrade memory is because low amounts of memory can lead to much use of the hard drive and based n the fact that it is not costly to upgrade memory than to upgrade the hard drive.

What is upgrading memory?

This is known to b an act done so as to improve the performance of a computer.

It is often known as a RAM or system memory upgrade. An upgrade implies that one is adding memory modules along with the ones that were there or replacing the old ones. It is less costly when compared to hard drive upgrade.

Learn more about Upgrade memory  from

https://brainly.com/question/13196228

Most graphics software programs give you the choice to work in either RGB or CMYK. What are these specifications called?
A.
digital codes
B.
color spaces
C.
computer graphics
D.
artwork

Answers

A - digital codes

Hope I’m right

Answer:B

Explanation:

// This pseudocode segment is intended to compute and display
// the average grade of three tests for any number of students.
// The program executes until the user enters a negative value
// for the first test score.
start
Declarations
num test1
num test2
num test3
num average
housekeeping()
while test1 >= 0
mainLoop()
endwhile
endOfJob()
stop

housekeeping()
output "Enter score for test 1 or a negative number to quit"
return

mainLoop()
output "Enter score for test 2"
input test2
average = (test1 + test2 + test3) / 3
output "Average is ", average
output "Enter score for test 1 or a negative number to quit"
input tesst1
return

endOfJob()
output "End of program"
return

Answers

The pseudocode to calculate the average of the test scores until the user enters a negative input serves as a prototype of the actual program

The errors in the pseudocode

The errors in the pseudocode include:

Inclusion of unusable segmentsIncorrect variablesIncorrect loops

The correct pseudocode

The correct pseudocode where all errors are corrected and the unusable segments are removed is as follows:

start

Declarations

     num test1

     num test2

     num test3

     num average

output "Enter score for test 1 or a negative number to quit"

input test1

while test1 >= 0

     output "Enter score for test 2"

     input test2

     output "Enter score for test 3"

     input test3

     average = (test1 + test2 + test3) / 3

     output "Average is ", average

     output "Enter score for test 1 or a negative number to quit"

     input test1

endwhile

output "End of program"

stop

Read more about pseudocodes at:

https://brainly.com/question/11623795

In programming 2+6 is an example of what math

Answers

Answer:

[tex]beinggreat78~here~to~help.[/tex]

2 + 6 in programming is an example of math. It is the same as in the real world. Plus signs in coding are also a form of string concatenaction, the term used for combining two strings into one, or a variable into a string.

Put the steps of the decision-making process in the correct order.
1. Step 1
Gather data.
2. Step 2
Analyze choices.
3. Step
Make the decision.
4. Step 4
Evaluate the decision.
5. Step 5
Determine the goals.

Answers

Answer:

step 5, step 1, step 2, step 3, step 4

Explanation:

I belive that would be the answer. I hope this helps.

What does the standard deviation of a set of data tell you?
O A. The smallest data value
B. Whether the data are spread out or not
O C. How many data points there are
O D. The maximum value of the data
SU

Answers

Answer: It tells us about how our set of data is spread out as compared to our mean or expected value.

Explanation: Note: Standard deviation is represented by Greek Letter sigma.For example: A teacher in a class of particular students takes a learning ability test from the students. Average or mean marks of students is 52 with +/- 10 marks. Then 1σ (Sigma = standard deviation) it means 1 standard deviation = 68% students will lie in between 52 + 10 =62 marks and 52-10 = 42 marks region.  2σ (2 standard deviation) means among the students 95% of them will lie between 52 + 20 =72 and  52-20= 32 marks region.3σ (3 standard deviation) means 99.7% of the students will lie in the region where 52 + 30 = 82 and 52 – 30 = 22 marks region.  So for 3σ (3 Standard Deviations), only 0.3% of the total students deviate +/-30 marks from the average. It means 0.15% students will have marks less than 22 and 0.15%  students will have marks greater than 82.  In the schematic attached, I have tried to make you understand through a diagram. Please refer to the schematic 1.  It tells us about the how our set of data is spread out as compared to our average or mean. And distance from mean can be calculated through number of standard deviations that the data is how much below or above the average.For example:For 1σ 68% students will come under the curve of “Average Learners”  and rest of 32% will come under the curve of “Poor Learners” and “Very Talented Learners”.For 2σ 95% of the students will come under the curve of “Average Learners”  and rest will come under the curve of “Poor Learners” and “Very Talented Learners”.For 3σ 99.7% of the students will come under the curve of “Average Learners” and rest of 0.3% will come under the curve of “Poor Learners” and “Very Talented Learners”.

a) Explain any two problems associated with the existing system used by the organization. (25 marks)​

Answers

Answer:

Lack of Strategy

Many of the most common MIS issues can be traced back to a lack of a solid strategy. Information systems leaders are well aware of the many tools available to gather data on their network. But putting that information to use is often a challenge.

At one time, technology departments served as a separate operation, providing tech support and keeping an organization’s server equipment running. Today, MIS leadership often sits alongside other business leaders, working together to ensure that the technology being used supports the overall mission of the company moving forward.

Meeting Organizational Needs

MIS plays an ever-increasing role in organizations, with professionals relying on technology for every aspect of operations. Sales and marketing rely heavily on customer relationship software to track client interactions, for instance, while accounting needs its own software for billing, invoicing and financial tracking.

With more than half of all companies now relying on big data analytics, MIS is playing an even more important role. Before making a decision, today’s management teams are likely to pull reports on existing activity to ensure they use facts rather than make educated guesses.

Explanation:

Steps of booting a computer

Answers

Steps of Booting
The Startup. It is the first step that involves switching the power ON. ...
BIOS: Power On Self Test. It is an initial test performed by the BIOS. ...
Loading of OS. In this step, the operating system is loaded into the main memory. ...
System Configuration. ...
Loading System Utilities. ...
User Authentication.

6. Which of the following items is not a storage
medium?
A. Plotters
B. Zip disk
C. Hard disk
D. Memory stick

Answers

Answer:

Plotters

Explanation:

A 'plotter' is an external hardware device like a printer used with a computer to 'print vector graphics' - basically in english it no hold storage like that

What year was internet inverted

Answers

[tex]\large\blue{\mid{\underline{\overline{\tt { →\:January \:1, 1983}\mid}}}}[/tex]

ARPANET→Advanced Research Projects Agency Networkthe forerunner of the Internet.

[tex]\purple{\rule{15mm}{2.9pt}} \red{\rule18mm{2.5pt}} \orange{ \rule18mm{2.5pt}}[/tex]

[tex]\sf{\:мѕнαcкεя\: ♪...}[/tex]

i need the full code for 6.1.3 code hs circles and squares please answer please help

Answers

In this exercise we have to use the knowledge in computational language in python  to write a code with circles and squares.

how to draw geometric figures in python?

inputs = 100

radius

   draw_circle(radius);

   pendown()

   begin_fill()

   circle(radius)

   end_fill()

   penup()

left(90)

forward(radius*2)

right(90)  

penup()

setposition(0,-200)

color("gray")

bottom_radius = int(input("What should the radius of the bottom circle be?: "))

draw_circle(bottom_radius)

draw_circle(bottom_radius)

See more about python at brainly.com/question/18502436

I of 60
MUL
FINISI
a
The view in which the field data types and field properties for a database table can be seen in Microsoft
Access is called the...
0.5 POINTS
A
00
Datasheet view
B
design view
с
D
SQL view
dashboard view
E
field view

Answers

The view in which the field data types and field properties for a database table can be seen in Microsoft Access is called the Datasheet view.

What is datasheet view?

A datasheet form is known to be the view that shows a user the information recorded using a table.

Note that the properties of a field tells users the characteristics and attributes of data added to that field. A field's data type is therefore a vital  property as it helps one to know the kind of data the field can save.

Learn more about database  from

https://brainly.com/question/26096799

Fumiko is a network technician. She is configuring rules on one of her company's externally facing firewalls. Her network has a host address range of 192.168.42.140-190. She wants to allow all hosts access to a certain port except for hosts 188, 189, and 190. What rule or rules must she write

Answers

The rule that she must write is that  A single rule allowing hosts 140–187 is all that is necessary; the default-deny rule takes care of blocking the remaining nonincluded hosts.

What is a Firewall?

A firewall is known to be a form of a network security device that helps one to manage, monitors and filters any form of incoming and outgoing network traffic.

This is often done based on an firm's formerly set up security policies. A  firewall is known as the barrier that exist between a private internal network and the public Internet.

See options below

What rule or rules must she write?

a) A single rule allowing hosts 140–187 is all that is necessary; the default-deny rule takes care of blocking the remaining nonincluded hosts.

b) Multiple rules are necessary for this configuration; one or more rules must define Deny exceptions for 188, 189, and 190, followed by the Allow rule for the 140–190 range.

c) A Deny rule is needed for 188, 189, and 190, and then exception rules for the 140–187 range.

d) The default Deny all rule needs to be placed first in the list, and then an exception rule for the 140–187 range.

Learn more about firewalls from

https://brainly.com/question/13693641

It is possible to publish a presentation online. True False

Answers

Answer:

It should be true

Explanation:

I don't see why it wouldn't

Consider the following program written in C syntax:
void swap(int a, int b) {
int temp;
temp = a;
a = b;
b = temp;
} void main() { int value = 2, list[5] = {1, 3, 5, 7, 9};
swap(value, list[0]);
swap(list[0], list[1]);
swap(value, list[value]);
}
For each of the following parameter-passing methods, what are all of the
values of the variables value and list after each of the three calls to
swap?
1. Passed by value
2. Passed by reference
3. Passed by value-result
6.

Answers

The values of the variables value and list after each of the three calls to

swap are:

value = 2 and  list[5] = {1, 3, 5, 7, 9};value = 2 and  list[5] = {3, 1, 5, 7, 9};value = 2 and  list[5] = {3, 1, 5, 7, 9};

How to determine the values of variable value and the list?

1. Passed by value

In this case, the values of the actual arguments remain unchanged; So the variable value and the list would retain their initial values

The end result is:

value = 2 and  list[5] = {1, 3, 5, 7, 9};

2. Passed by reference

With pass by reference, the arguments are changed.

Given that

value = 2 and  list[5] = {1, 3, 5, 7, 9};

The value of variable value is swapped with list[0].

So, we have:

value = 1 and  list[5] = {2, 3, 5, 7, 9};

Then list[0] and list[1] are swapped

So, we have:

value = 1 and  list[5] = {3, 2, 5, 7, 9};

Lastly, value and list[value] are swapped

So, we have:

value = 2 and  list[5] = {3, 1, 5, 7, 9};

The end result is:

value = 2 and  list[5] = {3, 1, 5, 7, 9};

3. Passed by value-result

Since there is no loop in the program, the pass by value-result has the same output as the pass by reference.

So, the end result is:

value = 2 and  list[5] = {3, 1, 5, 7, 9};

Read more about C syntax at:

https://brainly.com/question/15705612

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

Other Questions
Which of the following best describes a piece of flash fiction? A. A quick-moving story, in which the fast pace is part of the enjoyment. B. A plot-driven story, in which each event has complex repercussions. C. A heavily edited story, in which the most vivid details are taken out. D. A highly descriptive story, in which setting is particularly important. 1. Solve 2(x + 1)^2 = 18. What are the x-intercepts? What is the value of z? Enter your answer in the box Find the value of cos Q rounded to the nearest hundredth, if necessary. A(t)=3(2) and W(t)=30t-70 which is smaller, A(4) or W(4) probably extremely easy but would like a little explanation on doing this when it comes to this specific subject If made $90.00 how much was paid hourly? I think of a number and add one fourth of it to half of it and the result is twelve. What is the number I thought of? Which of the following is the correct definition of nuclear energy? A. energy of an object due to the random motion of its atoms and molecules B. energy an object has because of its motion or position C. energy produced from the splitting of atoms D. energy resulting from the flow of charged particles, such as electrons or ions Nathan is comparing the cells from a species of amoeba with a species of bacteria. Both species are unicellular, meaning individuals exist as a single cell. Which characteristic of the cells should Nathan expect to be the same in both species?A. The size and shape of the cellB. The method of reproduction, or making more cells of the speciesC. The organization of DNA into structures such as chromosomes and the cell nucleus.D. The genetic code that has used by DNA and RNA to direct protein synthesis Question 6 of 10Which chronic disease may be prevented by regular visits to the dentist?O A. Oral cancerO B. ObesityO C. AllergiesO D. EmphysemaSUBMIT Which term does not belong when discussing total taxable income? I have a few questions in social studies im stuck on and its bringing down my grades I need help for this question real quick. Please help if you can When preparing for exams, it is healthy for you to learn into dawn or to sleep and have enough rest? What is pulp used to make? What is the volume? Answer asp Why did President Truman decide to drop the atomic bomb on Japan ? Atomic scientists convinced him it was the best way to test the new weapon He sought revenge against the Japanese for bombing Pearl Harbor The American people demanded that he use the deadly weapon believed it was the only way Japan would accept an unconditional surrender I NEED THIS DONE!!! 50 POINTS!!! PLEASE HELP What is a parenthetical element