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

Write a RECURSIVE function that prints the values of an array to the console in

ID: 3645881 • Letter: W

Question

Write a RECURSIVE function that prints the values of an array to the console in reverse order, that is, prints the last value of the array, then the second last, etc. Your main() function should initialize the array, (you can use the { } method to initialize it), and print the values in the intial array to the console before calling the function to print the array elements backwards. Note: you do not need to modify the array, just print the values in the array.

The function header will look like

void writeArrayBackwards( int myArray[], int size)

Example:

original: 1, 3, 5, 6, 2

backwards: 2, 6, 5, 3, 1


This is what I have so far. Im not opposed to having an entirely new code so feel free to just give me a whole new code.

void writeArrayBackwards(int myArray[], int size)
{
if (size == 1)
cout<< myArray[0]<<" ";
}

else
{
writeArrayBackwards(myArray[], size-1);
}
}
int main()
{
int myArray[];
int size;

return 0;
}

Explanation / Answer

void writeArrayBackwards(int myArray[], int size) { if (size == 1) cout
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