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
pashok25 [27]
3 years ago
8

Write a program that first gets a list of integers from input. Then, get another value from the input, and output all integers l

ess than or equal to that value. If the input is 5 50 60 140 200 75 100, the output is: 50 60 75.
Computers and Technology
1 answer:
jonny [76]3 years ago
5 0

Answer:

The c++ program for the given scenario is given below.

#include <iostream>

using namespace std;

int main() {

   int len=20, arr[len], data;    

   // initialize all elements of the array to 0

   for(int i=0; i<len; i++)

   {

       arr[i] = 0;

   }    

   cout<<"This program outputs all the numbers less than or equal to the given number."<<endl;

   cout<<"Enter the list of numbers. Enter 0 to stop entering the numbers. "<<endl;

   for(int i=0; i<len; i++)

   {

       cin>>arr[i];        

       // 0 indicates user wishes to stop entering values  

       if(arr[i] == 0)

           break;

       else

           continue;

   }    

   // number from which the list is to be compared

   cout<<"Enter the number to be compared."<<endl;

   cin>>data;

     

   cout<<"The values less than or equal to the number "<<data<<" are "<<endl;

   for(int i=0; i<len; i++)

   {  

       // 0 indicates the end of the list entered by the user

       if(arr[i]==0)

           break;

       if(arr[i] <= data)

           cout<<arr[i]<<endl;

   }    

   return 0;    

}  

OUTPUT

This program outputs all the numbers less than or equal to the given number.

Enter the list of numbers. Enter 0 to stop entering the numbers.  

23

45

67

89

10

0

Enter the number to be compared.

59

The values less than or equal to the number 59 are  

23

45

10

Explanation:

This program takes input only from the user and makes no assumptions.

The list of numbers entered by the user are stored in an array. If the user input is less than the size of the array, the remaining elements are set to 0.

While taking input from the user, if any element of the array is found to be 0, the loop is discontinued.

for(int i=0; i<len; i++)

   {

       cin>>arr[i];        

       if(arr[i] == 0)

           break;

       else

           continue;

   }  

Same test is applied when all the numbers less than the given number are displayed.

for(int i=0; i<len; i++)

   {  

        if(arr[i]==0)

           break;

       if(arr[i] <= data)

           cout<<arr[i]<<endl;

   }

The above program takes into account all the specifications in the given question.

You might be interested in
Please help me please i’ll give brainli
DaniilM [7]
Answer: a digital bulletin board
4 0
3 years ago
Which of the following is least likely to be a scientific experiment?
enot [183]
It would be the last one, because she isn't recording any type of data over what she is doing and she isn't observing it at all. She simply trimmed the stems of a bouquet of flowers. However, the other options insist that they are recording data and observing, like you would do when performing an experiment. I hope this helps! :)
8 0
3 years ago
Read 2 more answers
3
Yuki888 [10]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

There are some steps that you use to access the subtotal dialog box.

To access the Subtotal dialog box, you need to follow the following steps:

Click the Date tab

In the  Outline group, click Subtotal

to access the Subtotal dialog box.

The Subtotal function used in Excel and return the subtotal of the numbers in a column in a list or database. Subtotal is a builtin function in Excel that used to subtotal the number in a column or in a given database.

4 0
3 years ago
Read 2 more answers
Explain pervasive value system
luda_lava [24]
Persuading people they need your service/ product would be valuable to you
4 0
4 years ago
JUST NEED TO KNOW WHO ALL DOSE EDGINUITY
grandymaker [24]

Answer:

I don't use it but my little brother does and I help him with it.

3 0
3 years ago
Read 2 more answers
Other questions:
  • Why might a programmer prefer the top-down approach to programming
    7·2 answers
  • Return to the Product Mix worksheet. Benicio wants to provide a visual way to compare the scenarios. Use the Scenario Manager as
    6·1 answer
  • A machine that is used to print newspaper is a
    12·2 answers
  • Write a program that completes the following requirements in C program:
    14·1 answer
  • Be able to list a technology-based company and discuss whether it enjoys sustainable competitive advantage based on the resource
    13·1 answer
  • the moon is about 240,000 miles from the earth what is this distance whitten as a whole number multiplied by the power of ten
    10·1 answer
  • What does "scanf(\"%d\" mean?
    13·2 answers
  • Mikaya works in the planning department
    14·2 answers
  • Edhesive assignment 7 calendar
    10·1 answer
  • What is 11100111 to decimal form?
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!