Ask Question
14 January, 13:57

9.16 Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers 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. Ex: If the input is: 5 25 51 0 200 33 0 50 then the output is: 25 0 33 (the bounds are 0-50, so 51 and 200 are out of range and thus not output).

+3
Answers (1)
  1. 14 January, 14:19
    0
    The following are the program in the C+ + programming Language.

    //set header file

    #include

    //set header file

    #include

    //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 a;

    //set the for loop

    for (int i = 0; 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
    {

    //check the minimum and the maximum elements

    if (a[i]>=minimum && a[i]<=maximum)

    {

    //print the elements

    cout<
    }

    }

    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.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “9.16 Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers