Question: Debug and fix issues C++ #include using namespace std; // Function Prototype int arrayAllocator(int); int main() { int numElements, // To hold the number of

Debug and fix issues C++ #include  using namespace std; // Function Prototype int arrayAllocator(int); int main() { int numElements, // To hold the number of elements to allocate int pointer = nullptr; // A pointer to the array int i; // A loop counter // Get the array size. cout << " Enter an array size: "; cin >> num; // Allocate the array. pointer = arrayAllocator(numElements); // Fill the array with values. for (i = 0; i < numElements; i+) pointer[] = i; // Display the values. cout << "Here are the values in the array: "; for (i = 0; i < numElements; i++) cout << "Element " << i << " has the value " << pointer[] << endl; // Deallocate the array. delete [] pointer; pointer = nullptr; return 0; } // ******************************************************** // The arrayAllocator function dynamically allocates an * // array of ints. The number of elements is passed as an * // argument into the parameter num. The function returns * // a pointer to the array. * // ******************************************************** int* arrayAllocator(int num) { int *arrPtr = nullptr; // Allocate space for the array. arrPtr = new int[num]; // Return the address of the allocated memory. return arr; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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

Students Have Also Explored These Related Databases Questions!