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
What is one way to process your thoughts about the information you are reading?
tatuchka [14]
Make a connection to what you already know about the material
4 0
3 years ago
If you could represent yourself with one object from your home what would it be ?
user100 [1]

Answer:

cross

bc im religous and stuff (0_0)

8 0
2 years ago
Read 2 more answers
True/False: If a function is legally prototyped to return an integer value, it can return a structure member that is an integer
sdas [7]
#1) If a function is legally prototyped to return an integer value, it can return a structure member that is an integer data type.
Answer: True. Any method that is not declared void must contain a return statement with a corresponding return value. The data type of the return value must match the method's declared return type; you can't return an integer value from a method declared to return a boolean.
5 0
3 years ago
Frank has created a résumé and separated the sections using headings. How can he set the headings apart from normal text?
Pepsi [2]
He could use bold or bigger text just a suggestion.
6 0
3 years ago
Describe who was Alan Turing in 100 words.<br> First to answer will get brainliest.
NNADVOKAT [17]

Answer:

Alan Turing, in full Alan Mathison Turing, (born June 23, 1912, London, England—died June 7, 1954, Wilmslow, Cheshire), British mathematician and logician who made major contributions to mathematics, cryptanalysis, logic, philosophy, and mathematical biology and also to the new areas later named computer science, cognitive science, artificial intelligence, and artificial life.

Explanation:

Turing was a founding father of artificial intelligence and of modern cognitive science, and he was a leading early exponent of the hypothesis that the human brain is in large part a digital computing machine.Alan Turing was one of the most influential British figures of the 20th century. In 1936, Turing invented the computer as part of his attempt to solve a fiendish puzzle known as the Entscheidungsproblem.

5 0
2 years ago
Other questions:
  • What does raster graphic mean
    5·1 answer
  • How can you differentiate between standard and protocol? Write at least on example of each of these terminologies?
    12·1 answer
  • Which function should be used to display a value based on a comparison?
    11·1 answer
  • Write a method called swapPairs that switches the order of values in an ArrayList of strings in a pairwise fashion. Your method
    9·1 answer
  • Please help!! Even if you help a little I will be very thankful!
    7·1 answer
  • PLEASE HELP!! WILL MARK BRAINLIEST!!
    9·1 answer
  • Write an application that inputs a five digit integer (The number must be entered only as ONE input) and separates the number in
    10·1 answer
  • assume there are K sorted lists, each of n/k elements. We want to merge them into a single sorted list of n elements. Give an op
    7·1 answer
  • Please answer this question​
    6·1 answer
  • What kind is a utility file that shrinks the size of a file
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!