Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

Students also viewed these Databases questions

Question

6. List outcomes of the adaptation process.

Answered: 1 week ago