Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am having trouble completing the 4th bullet in Step 2. I have provided the bot

ID: 3692493 • Letter: I

Question

I am having trouble completing the 4th bullet in Step 2. I have provided the bottom half of my code from Notepad++. The top half (not shown) is just code that pertains to Step 1 in main and is not important for this question. Step 2 takes place inside the function arrayManipulator which I have provided (lines 43-60) and I have also completed up to the 3rd bullet. I have also included a function prototype for it before main in case you're wondering. For the 4th bullet, the key point to remember is that only pointers are allowed to achieve reversing the order of the array. Please stick to the C++ language style shown.

Explanation / Answer

/** C++ code to reverse elements of array using pointers **/

#include <iostream>
#include <stdio.h>
#include <stdlib.h> // For random(), RAND_MAX

using namespace std;

int* ArrayManipulator( int *arraypointer, const int size )
{
int *ReversedArray = new int[size];

for (int i = 0; i < size; ++i)
{
ReversedArray[i] = arraypointer[i];
cout << ReversedArray[i] << " ";
}
cout << endl;

int c,d;
for ( c = size - 1, d = 0 ; c >= 0 ; c--, d++ )
*(ReversedArray+d) = *(arraypointer+c);

for ( c = 0 ; c < size ; c++ )
*(arraypointer+c) = *(ReversedArray+c);
return ReversedArray;
}

int main()
{
srand(time(NULL));
int N ;
cout << "Enter N: ";
cin >> N;

while( N >= 30 || N < 0)
{
cout << "Invalid Input, Enter N again: ";
cin >> N;
}

int *randomnums = new int[N];
int y;

for (int i = 0; i < N; ++i)
{
y = 1 + rand() %100;
randomnums[i] = y;
cout << randomnums[i] << " ";
}

cout << endl << endl;
int * ReversedArray = ArrayManipulator( randomnums, N);

cout << " Reversed Array: " << endl;
for ( int i = 0; i < N; i++ )
{
cout << ReversedArray[i] << " ";
}

cout << endl;
free(ReversedArray);
free(randomnums);
return 0;
}