Answered step by step
Verified Expert Solution
Question
1 Approved Answer
EGR 126 Exercise 11 -Print Vector The objective of this Exercise is to gain experience with filling and printing a numeric vector. This assignment is
EGR 126 Exercise 11 -Print Vector The objective of this Exercise is to gain experience with filling and printing a numeric vector. This assignment is similar to Exercise 9A, using a vector instead of an array Design a program to process several sets of data. For each data set, the program should read in the numbers, store them in a vector, and then print the numbers twice: first in the order read in (first to last), then in reverse order (last to first) The program should be general enough to handle multiple sets of data of differing lengths. You can design for this with nested looping. You will need an input value for the number of data sets to process. You will NOT need an input value for the size of each data set. You will use the size member function for this purpose You will need to decide how to determine the end of data (maybe a sentinel?). Since vectors are dynamically dimensioned, you need only declare the vector, but do not give it a dimension. You only need one vector, and will reuse that vector for reading each set of data. For simplicity, you may use an integer vector Using pseudocode for illustration, your progra m should do the following Request the user to supply how many data sets to input in this example nsets is used. For nsets iterations Use the member function push back to store the input values in the vector Use the member function size to determine how many entries are in the vector Print the values of the current data set in the order read in Print the values of the current data set in reverse order You may use screen or file as your input source You may use a function if you choose, but you are not required to use a function Use good formatting, and appropriate labeling Submit your program using three sets of data: 0 246 8 10 11 9753 1 01 2 34 3 -2 -1 1 2 3 5 Updated 104/2016 Page 1 of 1
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started