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
Scrat [10]
3 years ago
6

using C++ to sort user input. for example, user enter 25numbers and sort them from small to big or big to small, cout thesamlles

t, the middle one on the sort list ( in 25 number would bethe 13th number) and the biggest?

Computers and Technology
1 answer:
Umnica [9.8K]3 years ago
4 0

Answer:

C++ code:

#include<iostream>

using namespace std;

void sort(int al[30], int l)

{

//we use insertion sort to sort the array.

int p,q,k;

for(q=1;q<l;q++)   //starting from the 2nd item of the array.

{

 k= al[q];   //taking qth item as key value.

 p=q-1;

 while(p>=0 && al[p]>k)

 {

  al[p+1]=al[p]; //all items those are greaer than al[q] are shifted //to right.

  p=p-1;

 }

 al[p+1]=k;

}

}

int main()

{

int p,l, arrl[30];

cout<<"Enter the number of items in your array: ";

cin>>l;

cout<<endl;

 

cout<<"Enter your "<<l<<" items"<<endl;

for(p=0;p<l;p++)

{

 cin>>arrl[p];

}

 

sort(arrl, l);  //call function sort() to sort the array.

 

cout<<"The array after sorting: ";

for(p=0;p<l;p++)

{

 cout<<arrl[p]<<" ";

}

cout<<endl;

 

cout<<"The smallest item is: ";

cout<<arrl[0]<<endl;

 

cout<<"The middle item is: ";

cout<<arrl[l/2]<<endl;

 

cout<<"The biggest item is: ";

cout<<arrl[l-1]<<endl;

}

Output is given as image.

You might be interested in
Assuming your computer only has one network card installed; explain how your virtual machine is able to share that card with you
adell [148]

Answer and Explanation:

Virtual machine have one imitated organize connector and there is one of a kind MAC address is allocated with it.  

The system driver of the Virtual machine's performs all the task:  

  • The system driver places physical connector in 'promiscuous' mode implies physical connector will acknowledge all system parcel paying little heed to MAC address,then virtual machine's driver channels its bundles and direct it to the virtual machine.
5 0
3 years ago
What is the first step in finding a solution to a problem?
Law Incorporation [45]

Answer:

Can i have a points? Tysmm

5 0
3 years ago
Read 2 more answers
True/False: Each individual element of an array can be accessed by the array name and an element number, called a subscript. Tru
Dahasolnce [82]

Answer:

True

Explanation:

3 0
2 years ago
Suppose that the following elements are added in the specified order to an empty binary search tree: Lisa, Bart, Marge, Homer, M
Alecsey [184]

Answer:

Pre-order: Lisa, Bart, Homer, Flanders, Marge, Maggie, Smithers, Milhouse

In-order: Bart, Flanders, Homer, Lisa, Maggie, Marge, Milhouse, Smithers

Post-order: Flanders, Homer, Bart, Maggie, Milhouse, Smithers, Marge, Lisa

Explanation:

The required orders are mentioned.

4 0
3 years ago
Mitchell doesn’t have a checking account, but needs to pay a bill, what can Mitchell pay with?
aleksandr82 [10.1K]
Cash, possibly credit card.
5 0
3 years ago
Read 2 more answers
Other questions:
  • Wendy is an attacker who recently gained access to a vulnerable web server running Microsoft Windows. What command can she use t
    9·1 answer
  • Gunther is filling in his own input mask. He wants to format the Social Security numbers of his clients. The field must contain
    5·1 answer
  • 1. Extract title Write a function extract_title that takes one parameter, the filename of a GenBank formatted file, and returns
    14·1 answer
  • Which stage of the waterfall model is most like the simple model's stage 5?
    12·1 answer
  • What is a traditional tool used to align and mark vertical points from top to bottom?
    10·1 answer
  • Of all excavation hazards, _______ poses the greatest risk
    8·1 answer
  • PLEASE HELP AND FAST!!!!!<br>Which of the following devices uses binary code?
    6·2 answers
  • Which two statements are true about algorithms?
    15·2 answers
  • Amogus :0) owo have a good day y'all
    12·1 answer
  • Lattice-based access controls use a two-dimensional matrix to assign authorizations. What are the two dimensions and what are th
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!