Dynamically allocated array of ints

Assignment Help Business Management
Reference no: EM132244898

Need help with this homework problem.

Write a void function called transformArray that takes two parameters - a reference to a pointer to a dynamically allocated array of ints, and the size of that array.  The pointer is passed by reference because you want to change the value of the pointer. The function should dynamically allocate an array that is twice as long, filled with the values from the original array followed by each of those values times 2. For example, if the array that was passed in was {4, 2, 5}, then it should be replaced by {4, 2, 5, 8, 4, 10}. The address of the new array should be assigned to the pointer that was passed as a parameter.  The function should prevent any memory leaks. Remember to also prevent memory leaks in the main you use for testing.

For example, it could be used like this:

   int* myArray = new int[3];
   myArray[0] = 4;
   myArray[1] = 2;
   myArray[2] = 5;

   transformArray(myArray, 3);

   for (int i=0; i<6; i++)
      cout << myArray[i] << endl;

   delete []myArray;

The file must be named transformArray.cpp.

Reference no: EM132244898

Questions Cloud

Segmentation would not impact the marketing mix : Provide 2 examples from the automotive industry when segmentation would NOT impact the marketing mix.
Explain the changes in distribution intensity : In recent years, two nationally known health care providers established satellite facilities a great distance from their main clinical locations.
What is a task : What is a task? What is an event? What is a milestone?
Define relative emphasis that would be placed on advertising : Explain the relative emphasis that would be placed on advertising or personal selling in all three of the following situations in 250 words or more.
Dynamically allocated array of ints : Write a void function called transformArray that takes two parameters - a reference to a pointer to a dynamically allocated array of ints
How your innovation has potential to add ecological value : Demonstrate how your innovation has the potential to add Ecological Value.
Minimal and equivalent nondeterministic finite : Give an example of two different (i.e. non-isomorphic), minimal and equivalent Nondeterministic Finite Automata that both have two states only.
Write an essay on the drugs usign given information : Using the GCU Online Library and the Internet, research three sources and write a 750-1,500-word essay on the topic provided below.
What are the newest uses for device id : What are the Newest uses for Device ID's ? That also are beneficial in Marketing

Reviews

Write a Review

Business Management Questions & Answers

  Differentiate between supply chain management

Differentiate between supply chain management and a supply chain. Analyze the supply chain management process frameworks (SCOR and GSCF).

  Scope of complaints under the consumer protection act

What are the rights of a surety? Explain duties of a Bailor and a Bailee. “Power of Attorney is considered as an important concept in Business Law”. Explain “The Banking Regulation Act, 1949, provides various methods of regulation of the banking busi..

  Contrast a population and a sample

Contrast a population and a sample. Compare the difference between a qualitative and quantitative variable.

  Deference to agency decision making

During the New Deal, political liberals supported deference to agency decision making part beacuse the Court.

  Performance needs to be compatible

Why individual level performance and group level performance needs to be compatible?

  Discuss way rising diesel fuel prices are affecting decision

Briefly discuss three ways rising Diesel Fuel prices are affecting transportation decisions for US importers. Can these rising fuel costs ultimately be passed along to consumers?

  Internal-external forces influence organizational behavior

Examine how internal and external forces influence organizational behavior for each organization. Examples of internal and external forces.

  Theories for raising new capital

Theories for Raising New Capital - Explain how do companies decide in practice which route to follow in raising capital? The decision is complex and related to a company's balance sheet

  Number of tosses that you make

You toss a fair coin until a head appears. X is the count of the number of tosses that you make.

  What is the average non discounted gross profit in dollars

what is the average non discounted gross profit in dollars and cents (with no $ sign) during a customer’s lifetime?

  Where do you see the trends going in the future and why

Are these trends uniquely different for ancillary services vs. inpatient services? Where do you see the trends going in the future and why?

  Providing network and cybersecurity

In the context of IT jobs in the information system field a network administrator is typically responsible for providing network and cybersecurity.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd