Name the source file for this section stack.cpp. We are going to see what happens when we
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 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.
Elementary Statistics
ISBN: 978-0538733502
11th edition
Authors: Robert R. Johnson, Patricia J. Kuby