Answer:
The program implemented in C++ is as follows:
#include <iostream>
#include <vector>
using namespace std;
int main(){
int lenlist;
vector<int> mylist;
cout<<"Length List: ";
cin>>lenlist;
mylist.push_back(lenlist);
int i =0; int num;
while(i<lenlist){
cin>>num;
mylist.push_back(num);
i++;
}
int min,max;
cout<<"Min: "; cin>>min;
cout<<"Max: "; cin>>max;
cout<<"Output!"<<endl;
for(int i=1; i < mylist.size(); i++){
if(mylist.at(i)>=min && mylist.at(i)<=max){
cout<<mylist.at(i)<<" ";
}
}
return 0;
}
Explanation:
This declares the length of the list as integer
int lenlist;
This declares an integer vector
vector<int> mylist;
This prompts user for length of the list
cout<<"Length List: ";
This gets input of length of the list from the user
cin>>lenlist;
This pushes user input to the vector
mylist.push_back(lenlist);
int i =0; int num;
The following iteration gets user inputs and pushes them into the vector
<em>while(i<lenlist){
</em>
<em> cin>>num;
</em>
<em> mylist.push_back(num); </em>
<em> i++;
</em>
<em>}
</em>
This declares min and max variables
int min,max;
This prompts user for the lower bound
cout<<"Min: "; cin>>min;
This prompts user for the upper bound
cout<<"Max: "; cin>>max;
The following iteration checks for numbers within the lower and upper bound and print the numbers in that range
<em>cout<<"Output!"<<endl;
</em>
<em>for(int i=1; i < mylist.size(); i++){
</em>
<em> if(mylist.at(i)>=min && mylist.at(i)<=max){
</em>
<em> cout<<mylist.at(i)<<" ";
</em>
<em> }
</em>
<em>}
</em>