1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sidana [21]
2 years ago
9

Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer

s that follow. That list is followed by two more integers representing lower and upper bounds of a range. Your program should output all integers from the list that are within that range (inclusive of the bounds). For coding simplicity, follow each output integer by a space, even the last one. The output ends with a newline.
Ex: If the input is: 5 25 51 0 200 33
0 50

then the output is:
25 0 33
Computers and Technology
1 answer:
snow_tiger [21]2 years ago
3 0

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>

You might be interested in
What connector has 4 pins, is used for older IDE drives and some SATA drives, and can provide +5 V and +12 V power outputs?
Dominik [7]

Answer:

The correct answer to the following question will be "Molex connector".

Explanation:

The Molex connector can be used for power connections on some kind of device for just a disk drive as well as many other electronic devices including CD-ROMs, display chips, etc.

  • Inside a PC shell, the Molex connectors carry DC power to a device.
  • Most providers offer accessible connections, not only the Molex as well as AMP connectors.

So, it's the right answer.

3 0
3 years ago
Why is an ISA unlikely to change between successive generations of microarchitectures
QveST [7]
Someone answer this because I need to know as well
\
4 0
3 years ago
What is the benefit to displaying the merge codes in a document?
sergejj [24]

Answer:

The author will know where data will be inserted in the document.

Explanation:

5 0
3 years ago
Write 3 things that can't be done without technology.
bulgar [2K]

Answer:

Hacking Online Orders Math

Explanation:

4 0
3 years ago
Read 2 more answers
WHAT ACTIONS CAUSE SPAM ON LINKEDIN?
klio [65]

Answer:

LinkedIn has a very smart algorithm, and it has a very strict policy against spammers. Back in 2014, it deleted millions of accounts that were causing spam on LinkedIn.  

Spam occurs:  

1. When you send bulk of connect requests in a short time  

2. When you send irrelevant messages to prospects  

3. When you Perform overactivity  

4. When you use LinkedIn automation tools  

5. When you send spammy and sales-y messages  

All these actions cause spam on LinkedIn, and it immediately takes action against you by restricting your account temporarily or permanently.

4 0
3 years ago
Other questions:
  • Write a function that takes an array of integers and its size as parameters and prints the two largest values in the array. In t
    5·1 answer
  • What is malware short for?
    13·2 answers
  • PLZZZ HELP 30 POINTS!!
    14·1 answer
  • Select the correct answer.
    5·1 answer
  • Air circulation is caused by ... A Earth's rotation around the sun B winds that move vertically C moving air between hot and col
    11·1 answer
  • All of the following are aspects of the search process except?
    6·2 answers
  • What is the use of jacquard loom
    13·2 answers
  • Add me on blizzard none of my friends play ow<br> NADERJABER#2530
    8·1 answer
  • ProgrammingAssignment3
    8·1 answer
  • What instructions would a computer have the hardest time completing correctly
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!