Ask Question
22 December, 03:07

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 Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value. Assume that the list will always contain less than 20 integers. Ex: If the input is 5 50 60 140 200 75 100 the output is 50 60 75 The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. For coding simplicity, follow every output value by a space, including the last one. Such functionality is common on sites like Amazon, where a user can filter results.

+1
Answers (1)
  1. 22 December, 06:15
    0
    The program to this question as follows:

    Program:

    #include / /include header file.

    using namespace std; / /using name space.

    int main () / /main function.

    {

    int n, i, key; / /define variable.

    int a[n]; / /define array

    cout<<"Enter size of array : "; / /message.

    cin>>n; / /input number from user.

    cout<<"Enter array elements : "; / /message

    for (i = 0; i
    {

    cin>>a[i]; / /input array elements

    }

    cout<<"Enter a number:"; / /message

    cin>>key; / /input number.

    for (i = 0; i
    {

    if (a[i]<=key) / /if block

    {

    cout<
    }

    }

    return 0;

    }

    Output:

    Enter size of array : 7

    Enter array elements : 5

    50

    50

    75

    100

    200

    140

    Enter a number:100

    5

    50

    50

    75

    100

    Explanation:

    The description of the above program as follows:

    In this program first, we include a header file and define the main method in method we define variables and array that are "n, i, key and a[]". In this function, all variable data type is "integer". The variable n is used for the size of array and variable i use in the loop and the key variable is used for comparing array elements. Then we use an array that is "a[]" in the array, we use the for loop to insert elements form user input. Then we define a loop that uses a conditional statement in if block we check that array elements is less than and equal to a key variable. If this value is true so, we will print the remaining elements.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers