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
jenyasd209 [6]
3 years ago
13

Write a program that gets a list of integers from input, and outputs non-negative integers in ascending order (lowest to highest

). Ex: If the input is: 10 -7 4 39 -6 12 2 the output is: 2 4 10 12 39
Computers and Technology
2 answers:
zhannawk [14.2K]3 years ago
7 0

Answer:

Following are the code to this question:

#include <iostream>//defining header file

using namespace std;

int main()//defining main method

{

   int a[]={10,-7,4,39,-6,12,2};//defining single deminition array and assign value

   int i,x,j,t; //defining integer variable

   cout<<"Before sorting value: ";  

   for(i=0;i<7;i++) //using loop to print value

   {

       cout<<a[i]<<" ";//print value

   }

   cout<<endl <<"After sorting value: ";

   for(i=0;i<7;i++)//defining loop to sort value

{  

 for(j=i+1;j<7;j++)//count array value

 {

  if(a[i]>a[j]) //defining condition to inter change value

  {

      //performing swapping

   t=a[i];  //integer variable t assign array value

   a[i]=a[j];//swapp value

   a[j]=t;//assign value in array

  }

 }

}

for(i=0;i<7;i++) //defining loop to print value

   {

       if(a[i]>=0) //defining condition to check positive value  

       {

       cout<<a[i]<<" ";//print value

       }

   }

   return 0;

}

Output:

Before sorting value: 10 -7 4 39 -6 12 2  

After sorting value: 2 4 10 12 39  

Explanation:

Following are the description to the above code:

  • In the above program code, Inside the main method, an array a[] is declared that assign some value, and another integer variable "i, j, x, and t" is declared, in which variable "i and j" are used in the loop, and "x, t" is used to sort value.
  • In the next step, three main for loop is declared, in which the first loop is used to print array value.
  • In the second loop, inside another loop is used that sorts array values.
  • In the last loop, a condition is defined, that check the positive value in the array and print its values.
yanalaym [24]3 years ago
3 0

Answer:

integers=[]

while True:

      number=int(input())

      if number<0:

       break

      integers.append(number)  

print("",min(integers))

print("",max(integers))

Explanation:

You might be interested in
Which of the following resources is an example of a web-based application?
kompoz [17]
The answer will be google docs since it depends on a web and its an application. hope it helps

3 0
4 years ago
Which careers have the highest minimum experience requirement?
Dafna11 [192]
(B) CIO, because they make $308,561 per year and it wouldn’t be A cause they only make $140,265 per year nor would C .
8 0
3 years ago
Are engineers who help to develop products and projects by creating technical drawings
Alinara [238K]

Answer:

This is true but an Engineer is much more than that. They are the professionals of engineering, who do the invention, analyze, design and test complex systems, machines, structures, machines for fulfilling the functional objectives gadgets as well as the requirements while taking into consideration the limitations that come up due to practicality, safety, regulations, and cost.

Explanation:

Please check the answer section.

8 0
4 years ago
Choosing the “Quick Print” button will ____________.
harkovskaia [24]
Choosing the "Quick Print" button will print to the default print (Answer is B). The quick print function is accessible in the Quick Access Tool bar . By clicking the drop down arrow of the quick access tool bar it will let you choose different types of default access including your Quick print.
7 0
4 years ago
Bob works in a small office with a network of computers. Bob, along with all the other employees, is responsible for securing hi
miskamm [114]

Answer:

False

Explanation:

When an employee becomes the one responsible for the security of His own computer then the scenario does not define Network security. Network security is a usage of hardware and related software to provide protection to the underlying network architecture from unauthorized access and other anomalies related to networks.

5 0
3 years ago
Other questions:
  • . Stress can affect not only your health, but also other aspectsof your
    15·1 answer
  • What part of the communication feedback loop results in unclear communication?
    13·1 answer
  • Type two statements that use rand() to print 2 random integers between (and including) 100 and 149. End with a newline.
    15·1 answer
  • An access control system that grants users only those rights necessary for them to perform their work is operating on which secu
    6·1 answer
  • I need help with this problem please
    9·1 answer
  • Cheri needs to write a small program that interacts with the user. What step will allow her to do this?
    14·2 answers
  •  How does critically analyzing technology add value to interactions with people in personal and professional contexts?
    7·2 answers
  • Defensive programming is sometimes referred to as _________.
    5·1 answer
  • Suppose a webpage contains a single text field. We want to make the page such that a user can immediately start typing in the te
    11·1 answer
  • When you ____ an exception, you send a message that an error has occurred to another part of the program.
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!