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

Write a function that accepts an array of integers and the array\'s size as argu

ID: 3570784 • Letter: W

Question

Write a function that accepts an array of integers and the array's size as arguments. The function should create a copy of the array, except that the values should be reversed in the copy. The function should return a pointer to the new array. Write a main function which uses this function and asks users
for values in an array, outputting the reversed array afterwards.

Sample output:


How many numbers do you have in your array? 3
Enter value #1: 51
Enter value #2: 16
Enter value #3: 97
97 16 51

Need to use C++

Explanation / Answer

#include <iostream>

using namespace std;

int reverseArray(int, int, int *);

int main() {//start main

const int size = 5;

int array1 [size] = {10,20,30,40,50};

int newArray [size];

int* numptr = array1;

reverseArray(array1, size, numptr);

}//end main

int reverseArray(int array1[], int size, int *numptr) {//start function

int count;

cout << "This is the orginal array: " ;

while (numptr < &array1[4]) {//start while

cout << *numptr << " ";

numptr ++;

}//end while

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote