In: Computer Science
Write a program that first gets a list of 5 integers
from input. Then, get another value from the input, and output all
integers less than or equal to that value.
Ex: If the input is 50 60 140 200 75 100, the output is:
50 60 75
For coding simplicity, follow every output value by a space,
including the last one. Then, output a newline.
Such functionality is common on sites like Amazon, where a user can
filter results.
in CORAL PLEASE
// Create an array of size 5
integer array(5) nums
// Declare an integer x which is the last integer to input
integer x
integer i
// Get each number as input
for i = 0; i < nums.size; i = i + 1
nums[i] = Get next input
// Get last number as input
x = Get next input
for i = 0; i < nums.size; i = i + 1
// For each number, check if it is less than 6th number
if nums[i] < x
Put nums[i] to output
Put " " to output
I have written comments on what each line does and why it is required.
For proper indentation, please follow the screenshot below:
To understand it properly, follow the screenshot for a flowchart:
The output for your given input is as shown below:
Hope this is helpful. In case of any queries, feel free to comment. All the best :)