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
bagirrra123 [75]
3 years ago
4

Write a program that gets a list of integers from input, and outputs the integers in ascending order (lowest to highest). The fi

rst integer indicates how many numbers are in the list. Assume that the list will always contain less than 20 integers. Ex: If the input is:
Computers and Technology
2 answers:
PIT_PIT [208]3 years ago
8 0

Answer:

integers=[]

while True:

      number=int(input())

      if number<0:

       break

      integers.append(number)  

print("",min(integers))

print("",max(integers))

Explanation:

nevsk [136]3 years ago
7 0

The c++ program for the given problem is shown below along with the explanation of each step.

#include <iostream>

using namespace std;

int main() {

int arr[20];

       int count = 0, num, swap;

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

{

          arr[i] = 0;

}  

cout<<"Enter the integers to be sorted in ascending order.     Enter 0 to stop entering the integers. " <<endl;

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

    {

        cin>>num;    

        if(num != 0)

            {

                arr[i] = num;

                count++;

            }

        else

        {

            cout<<"The numbers entered have been recorded. "<<endl;

            break;

        }

    }

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

{

    for(int j=i+1; j<20; j++)

    {

        if(arr[i] != 0)

        {

            if(arr[i] > arr[j])

            {

                swap = arr[i];

                arr[i] = arr[j];

                arr[j] = swap;

            }

            else

                continue;

        }

        else

            break;

    }

}

cout<<"Total number of integers entered is "<<count<<endl;

cout<<"The numbers in ascending order are "<<endl;

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

    {

        if(arr[i] != 0)

            cout<<arr[i]<<endl;

    }

}

1. We use an integer array to hold the integers entered by the user. Hence, we declare integer variables and array of size 20. The variables and array is initialized to 0.

        int arr[20];

 int count = 0, num, swap;

Array initialization is done to ease the sorting and displaying of the elements. User enters 0 only to quit, hence, elements having value 0 indicates null values.

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

{

    arr[i] = 0;

}

2. The integers entered by the user are put in the array and counted simultaneously.

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

    {

        cin>>num;

   

        if(num != 0)

            {

                arr[i] = num;

                count++;

            }

        else

        {

            cout<<"The numbers entered have been recorded. "<<endl;

            break;

        }

    }

3. The integers in the array are sorted in ascending order using a third variable swap, for swapping the integers.

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

{

    for(int j=i+1; j<20; j++)

    {

        if(arr[i] != 0)

        {

            if(arr[i] > arr[j])

            {

                swap = arr[i];

                arr[i] = arr[j];

                arr[j] = swap;

            }

            else

                continue;

        }

        else

            break;

    }

}

4. Lastly, the number of integers entered and the integers in ascending order the displayed.

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

    {

        if(arr[i] != 0)

            cout<<arr[i]<<endl;

    }

You might be interested in
Help please!, explain what is missing and what needs to be changed if anything.
german

Using the computer language in JAVA to write a function code that output numbers in reverse

<h3>Writting the code in JAVA:</h3>

<em>import java.util.Scanner;</em>

<em>public class LabProgram {</em>

<em>    public static void main(String[] args) {</em>

<em>        Scanner scnr = new Scanner(System.in);</em>

<em>        int[] userList = new int[20];</em>

<em>        int numElements;</em>

<em>        numElements = scnr.nextInt();</em>

<em>        for (int i = 0; i < numElements; ++i) {</em>

<em>            userList[i] = scnr.nextInt();</em>

<em>        }</em>

<em>        for (int i = numElements - 1; i >= 0; --i) {</em>

<em>            System.out.print(userList[i] + " ");</em>

<em>        }</em>

<em>        System.out.println();</em>

<em>    }</em>

<em>}</em>

See more about JAVA at brainly.com/question/12975450

#SPJ1

8 0
2 years ago
A slide in Blake's presentation contained the following information:
deff fn [24]

Answer:

consistent phrasing is missing

Explanation:

If you will note carefully, the bullets are not in correct format. The model is missing. The correct one is as below.

Risks

The correct form of presentation is as below:

1. Risks

a. employees  

              a. physical illness

              b. mental illness

              c. death  

2. Customers  

              a.   complaints

              b.   downtime

3.  Benefits

However, the content seems to be complete now, and hence not anything else is required. And since its not something very tough to decide to go with, bite the bullet is certainly not an issue.  

3 0
3 years ago
Which of the following is not a language commonly used for web programming?
DerKrebs [107]
The answer would be Assembly language as assembly language is not used for web development, but rather is a low level programming language.

Please mark branliest if this helped!!
7 0
4 years ago
Read 2 more answers
Designing the right elements for the tasks that the user is attempting to perform is called ________.
skelet666 [1.2K]

Answer:

Interface design

Explanation:

INTERFACE DESIGN are design that are carried out on either a computer or a mobile phone or other devices that will suit the users by designing the style of the devices and how the device will look like which will inturn enable the user to easily carried out or performed any tasks they are want to perform with easy and without any lapses which is why it is important for INTERFACE DESIGN to be design with the right tools that the user can easily understand in order to access and perform their tasks effectively.

6 0
3 years ago
Lesson Name: The Origins of American Government
Kisachek [45]

IDK what this is try posting more info

5 0
4 years ago
Other questions:
  • Describe data center technology and its relevance to modern-day cloud computing. Support your opinion with cited information.( S
    14·1 answer
  • How are natural systems and engineered systems similar to one another?
    8·1 answer
  • Create and Provide complete program that includes a comments header with your name, course, section and other program details an
    9·1 answer
  • Which changes should be made to establish and maintain formal writing conventions? Select two options.
    10·1 answer
  • Write the definition of a class Counter containing:
    5·1 answer
  • Which of the following is an advantage of computer usage? *
    10·1 answer
  • List and explain three computing devices from the 20th century​
    13·2 answers
  • The best team in nba like right now
    8·2 answers
  • "Use onblur and onfocus to add red borders to the input elements when the user leaves without any input, and a green border if a
    8·1 answer
  • Which mechanism will move a port into a root-inconsistent state if bpdus coming from a certain direction indicate another switch
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!