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
Remi always works on several projects at a time. He has thousands of files saved on his computer. Yet he always seems to be able
astraxan [27]

Answer

the micmethod <-----made by myself

Explanation:

1. alphabetical order

2.put in empty folder

3.name folder after file put file in hard drive

4.a hard drive is also a usb

5.make hard drive into necklace and wear all the time

6. now u never lose it

4 0
3 years ago
Tab stops are useful when you want to?
Lelu [443]
Indentation and alignment are very noticeable on a printed page, so you will probably want to set the tab stops in your document precisely how you want them.


8 0
3 years ago
Susan wants to play softball and work after school. She cannot do both, so she decides to play softball. What is her opportunity
marta [7]
Opportunity cost is what you give up to do something else. Since she decided to play softball after school, she cannot work so the answer is B
5 0
3 years ago
Read 2 more answers
Which is the best practice for placing graphics on a slide?
lbvjy [14]
All the choices depend on the slide and the last one is a must. the first one should be for the introduction and conclusion and the second one should be used to make ideas conveyed in the presentation easier to understand.
5 0
4 years ago
Read 2 more answers
All the data points lie within UCL &amp; LCL and all of the data points are randomly distributed about the mean value central li
nata0808 [166]

Answer: Common causes

Explanation:

Variation comes from two sources, common and special causes. Lets you at this scenario, how long it takes you to get to school in the morning. Maybe it takes you 40 minutes on average. Some days it may take a little longer, some days a little shorter. But as long as you are within a certain range, you are not concerned. The range may be from 35 to 45 minutes. This variation represents common cause variation --- it is the variation that is always present in the process. And this type of variation is consistent, random and predictable. You don't know how long it will take to get to schooltomorrow, but you know that it will be between 35and 45 minutes as long as the process remains the same.

Now, in thecase of special cause variation suppose there was an accident on the road and there was heavy non moving traffic . How long will it take you to get to work? Definitely longer than the 35 to 45 minutes in your "normal" variation. Maybe it takes you an hour longer. This is a special cause of variation. Something is different. Something happened that was not supposed to happen. It is not part of the normal process. Special causes are not predictable, non random and are sporadic in nature.

6 0
3 years ago
Other questions:
  • The salespeople at hyperactive media sales all use laptop computers so they can have easy access to important data on the road.
    9·1 answer
  • To save a file so that it can be opened on most computers, select the _____ option.
    9·2 answers
  • Which of the following topics should you avoid bringing up during a college interview?
    10·2 answers
  • Which f the following is not a characteristic of igneous rock
    8·1 answer
  • What is the best computer for college?
    12·1 answer
  • What do I need to write ??
    14·1 answer
  • A technician receives an invalid certificate error when visiting a website with port 443 enabled. Other computers on the same LA
    8·1 answer
  • According to the text, the three IT trends that are having the greatest impact on the IT environment are:
    11·1 answer
  • In c++ 11, the ________ tells the compiler to determine the variable's data type from the initialization value.
    6·1 answer
  • Four differences between fourth and fifth generation of computers​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!