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
As you apply to college when should you apply for financial aid
Nataliya [291]

Answer:

after you are accepted in the college

Explanation:

You should apply for admission to the colleges you are interested in BEFORE filing your FAFSA. Once you are accepted to the colleges you have applied to, you can add those schools to receive financial aid award offers from when you file your FAFSA.

4 0
3 years ago
The modulus ( % ) actually gives you the ___________ of an integer division problem.
Svetlanka [38]
The answer is (e) sum
7 0
3 years ago
You send a report to your boss for feedback and she returns it to you with her edits noted in the electronic file. This Word fea
Lesechka [4]
Edits in the document are called, C. Track changes
3 0
3 years ago
Read 2 more answers
What is an efficiency target? Give an example of setting an efficiency target
Gennadij [26K]

Answer:

Goals help provide our everyday lives with structure, and operate similarly at the institutional level, offering organizations a low cost method of encouraging motivation, communication and accountability. In short, goals help organizations to achieve a variety of ends—including the reduction of energy waste.

Energy efficiency improvement goals, also known as energy efficiency targets, are intended reductions in energy over a specified time frame that have been defined in a SMART manner. Targets are useful because they can encourage decision makers to improve the use of energy in their communities and operations. Moreover, energy efficiency targets can have short or long term timeframes and can be implemented on various scales, ranging from the national level down to individual buildings. Cities should explore both mandatory public sector targets and voluntary private sector targets to forge energy-efficient communities.

4 0
3 years ago
While a computer is running the operating system remains in memory. true or false?
MrMuchimi
While a computer is running the operating system remains in memory is true.
8 0
3 years ago
Other questions:
  • 3) Write a program named Full_XmasTree using a nested for loop that will generate the exact output. This program MUST use (ONLY)
    6·1 answer
  • What are the 6 external parts of a computer
    14·1 answer
  • "Suppose that instead of always selecting the first activity to finish, we instead select the last activity to start that is com
    14·1 answer
  • Which of the following can you use to attach external hardware devices to a computer?
    11·2 answers
  • Jean has created a database to track all of this month’s family meals. To find an entry for lasagna, what would should Jean do?
    6·1 answer
  • Elizabeth works for a local restaurant at the end of her shift she read she’s required to write in the time that she arrived in
    14·1 answer
  • . How is using 0 / 1 or true / false in specifying digital an abstraction?
    11·1 answer
  • What is the full form of MOS<br>​
    10·1 answer
  • (C) Describe about the different types of computer<br> peripherals and memory devices.
    9·1 answer
  • Hypertext enables you to navigate through pieces of information by clicking the __________, that connect them.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!