write in c++  Write ONE program that contains the following (#includes are NOT necessary).  [Hint: be very careful with your pointer syntax] Write a function copies with two int parameters, named n and x. It should dynamically allocate a new array of size n.  The function should then copy the value in x to every position in the array. The function should return a pointer to the new array. In the main function, call the copies function from part 1. with size 5 and value -1.  Output the resulting array to the screen, and deallocate the array. In your main function, add code to declare and initialize two integer variables y and z to 10 and 3.  Then call the function increment which has the prototype below.  The call should result in incrementing the value in y by z (so y will become 13). void increment (int *a, int b); //do NOT define this function // this function adds b to the value pointed to by the first argument

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section10.2: Array Names As Pointers
Problem 2E
icon
Related questions
Question

write in c++ 

Write ONE program that contains the following (#includes are NOT necessary). 
[Hint: be very careful with your pointer syntax]

  1. Write a function copies with two int parameters, named n and x. It should dynamically allocate a new array of size n.  The function should then copy the value in x to every position in the array. The function should return a pointer to the new array.

  2. In the main function, call the copies function from part 1. with size 5 and value -1.  Output the resulting array to the screen, and deallocate the array.

  3. In your main function, add code to declare and initialize two integer variables y and z to 10 and 3.  Then call the function increment which has the prototype below.  The call should result in incrementing the value in y by (so y will become 13).

void increment (int *a, int b); //do NOT define this function
// this function adds b to the value pointed to by the first argument

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Concept of pointer parameter
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr