Respuesta :
Answer:
The following are the program in the C++ programming Language.
//set header file
#include <iostream>
//set header file
#include <vector>
//set namespace
using namespace std;
//define main method
int main()
{
//declare two integer type variables
int num, value;
//get input from the user
cin>>num;
//declare vector type integer array
vector<int> a;
//set the for loop
for(int i = 0;i<num;i++)
{
//get elements of the variable
cin>>value;
//puch back the elements
a.push_back(value);
}
//set integer type variables
int minimum, maximum;
//get minimum value from the user
cin>>minimum;
//get maximum value from the user
cin>>maximum;
//set the for loop
for(int i = 0;i<num;i++)
{
//check the minimum and the maximum elements
if(a[i]>=minimum && a[i]<=maximum)
{
//print the elements
cout<<a[i]<<" ";
}
}
return 0;
}
Output:
5 25 51 0 200 33 0 50
25 0 33
Explanation:
The following are the description of the program.
- Firstly, we set the required header files and the namespace then, define the main method and inside the main function.
- Declare two integer data type variables 'num' and 'value', then get the input from the user in the variable 'num'.
- Declare the vector type integer array variable 'a' then set the for loop that iterates from 0 and end at less than the variable 'num' then, get the elements of the array in the variable 'value' and push back in the array variable 'a'.
- Then, set two integer data type variables 'minimum' and 'maximum', get the minimum and the maximum value from the user in it for iterate loop.
- Finally, set the for loop and print the following elements of the array.
The program is an illustration of loops.
Loops are used to perform repetitive and iterative operations.
The program in C++ where comments are used to explain each line is as follows
#include <iostream>
#include <vector>
using namespace std;
int main(){
//This declares the length of the list as integer
int lenlist;
//This declares an integer vector
vector<int> mylist;
//This gets input of length of the list
cin>>lenlist;
//This pushes the 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
while(i<lenlist){
cin>>num;
mylist.push_back(num);
i++;
}
//This declares min and max variables
int min,max;
//This gets input for the lower bound
cin>>min;
//This gets input for the upper bound
cin>>max;
/*The following iteration checks for numbers within the lower and the upper bound and print the numbers in that range*/
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;
}
Read more about similar programs at:
https://brainly.com/question/20564672