Question: C++ Use what you learned about array reversal loops in the preceding exercise. Prompt the user to enter a list of up to 20 integers,

C++ Use what you learned about array reversal loops in the preceding exercise. Prompt the user to enter a list of up to 20 integers, and a non-numeric to quit. In a loop, read the inputs into an array you've already declared of length 20. Hint: you can detect the non-numeric has been entered, while reading in the values, using:

int number[20], i=0; while (cin >> number[i] && i < 20) //cin returns false if invalid entry (non-numeric) { i++; }

Print out the array, all elements on one line, terminated with a newline. Reverse the array by swapping elements. Re-print the array reversed.

Assuming the user will enter "1 2 3 4 5 q", your code should print: "Enter a list of up to 20 integers, and a non-numeric to quit: " "The original array is: 1 2 3 4 5" "The reversed array: 5 4 3 2 1"

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!