Lab 1 Dynamic Memory Allocation Read Instructions Carefully Least 10 Deducted Instructions Q43888969
Lab #1 Dynamic Memory Allocation
Read the instructions carefully. At least 10% will be deducted ifthe instructions are not followed.
You can view the General Lab Requirements page fordetails on the general lab requirements.
Do not prompt the user for input during the execution ofyour program. Do not pause at the end of the execution waiting forthe user’s input.
Use an IDE to create the program Lab1c.cpp as follows.
(Lab1c.cpp) Write Lab1c.cpp in the following order.
Write A FunctionPrototype
Write a function prototype for the function namedallocIntArray. The function receives an integerparameter for the number of integer values the allocated memory cancontain. The function returns a pointer to the first integer valuein the allocated memory.
Write The MainFunction
Define and initialize a pointer named ptr1 for pointing to an intvalue.
Define and initialize a pointer named ptr2 for pointing to an intvalue.
Allocate an array that can contain 100 int values by callingallocIntArray and assign the returned pointer to ptr1.
Store odd numbers starting from 1 into the array.
Allocate an array that can contain 1000 int values by callingallocIntArray and assign the returned pointer to ptr2.
Store even numbers starting from 2 into the array.
Print partial contents of the first array on the screen.
Print partial contents of the second array on the screen.
Delete the memory allocated for the first array.
Delete the memory allocated for the second array.
Write the functiondefinition for allocIntArray
Write the block comment that describes the function name, what thefunction does, the parameter and the return value.
In the function body,
Use the new operator to allocate an array of integers using theparameter as the size of the array.
Return the pointer that is returned by the new operator.
Test theprogram
The output should look exactly as follows.
1 3 5 … 195 197 199
2 4 6 … 1996 1998 2000
Expert Answer
Answer to Lab #1 Dynamic Memory AllocationRead the instructions carefully. At least 10% will be deducted if the instructions are n…
OR