Question: Name the source file for this section stack.cpp. We are going to see what happens when we try to write a function that *returns* an

Name the source file for this section stack.cpp.

We are going to see what happens when we try to write a function that *returns* an array, without using the "new" keyword.

Write a function named gimmieArray, that takes an int named size as an argument, and returns an array of int. The function should declare an int array with a size equal to the input parameter and then return that array as the result.

Write a main function that calls gimmieArray to get a new array of size 10000000, then try to loop through that array outputting each element to the console.

This program should exit with some sort of segmentation fault when run.Your function signature should look like this: int* gimmieArray(int size)

New

Name the source file for this section new.cpp.

Let's write a proper function that returns an array. Write a function named newIntArray that accepts two integers as arguments: the first is the size of the new array wanted, and the second is the int that every element should be initialized to.

Write a main function that calls newIntArray to get a new array, and then test that each element is initialized to the value you specified. You will be graded on the completeness and correctness of your test code just as much as your other code.

Concat

Name the source file for this section concat.cpp.

Write a function named concat that returns an array of int.

concat takes 4 parameters as input:-

int*: The first array.

int : The size of the first array.

int*: The second array.

int : The size of the second array.

concat creates and returns a new array whose contents are the elements of the first array followed by the elements of the second array. The following pseudocode shows the desired behavior of concat::

concat([1, 2, 3], 3, [7, 8, 9], 3) == [1, 2, 3, 7, 8, 9]

The above is only pseudocode, it is not valid C++. Write a main function tests that concat works properly. You will be graded on the completeness and correctness of your test code just as much as your other code.

Feel free to copy your newIntArray function into this source code to make your test code a bit easier.

Step by Step Solution

3.44 Rating (154 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This question is complete Lets address it by dividing it into sections based on the requirements Section 1 Stack Allocation Issue stackcpp Task Write ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

60964641ed2f7_26756.pdf

180 KBs PDF File

Word file Icon

60964641ed2f7_26756.docx

120 KBs Word File

Students Have Also Explored These Related Programming Questions!