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
Every time I try to look up anything on my laptop it keeps saying my connection is not priavte what do I do
dangina [55]

You can click "Advanced" and still proceed to the website.


Please mark this answer as the Brainliest! Thank you :)




6 0
3 years ago
Read 2 more answers
Who knows a website that can connect videos in your phone
Arte-miy333 [17]
Get a screen recorder then record all the videos u wanna save then u can go back and watch them wenever u want to
5 0
3 years ago
A weak fuel to air mixture along with normal airflow through a turbine engine may result in?
Sladkaya [172]

Answer:

A weak fuel to air mixture along with normal airflow through a turbine engine may result in <u>a lean die out</u>.

Explanation:

Lean die out is a type of problem that may occur in the turbine. This may result in the weak fuel to air mixture. In case if the mixture of fuel and air is getting low due to some reasons like leakage of gas or low speed of engine may result in dangerous conditions such as fire or blast in the turbine. This is called lean die out. In the result of this problem, the turbine can be burn with the blast and may leads to causalities.

5 0
3 years ago
Jamie has to enter the names, grades, and scores of a group of students into a worksheet. Which option will Jamie use to describ
inessss [21]

Answer:

B. Graphs

Explanation:

Graphs are used to put certain things into categories. In this case Jamie has to enter different categories such as names, grades and the scored of the students. C and D don't make sense for this problem since they aren't actually what he is looking for. A is plausible but he needs it into a worksheet and labels aren't worksheets they are just labels. So B would be your answer. Also I took the quiz this is the correct answer.

8 0
3 years ago
Prior to the world wide web as we know it today, the internet was chaotic, without any ____.
atroni [7]
Search engines - there was no single way to ask a question
5 0
3 years ago
Other questions:
  • What is are example of an engineered item?
    12·1 answer
  • A technician wants to create a new partition on a new additional hard drive. what tool should be used?
    15·1 answer
  • Technologies designed to replace operating systems and services when they fail are called what?
    15·1 answer
  • How many mustangs are built every day
    13·2 answers
  • Convert octal number 2470 to decimal number
    14·2 answers
  • Combining two or more cells to make one is called​
    8·1 answer
  • Who innovated an aeroplane? ​
    5·1 answer
  • You are interested in buying a laptop computer. Your list of considerations include the computer's speed in processing data, its
    11·1 answer
  • #done with school already
    14·1 answer
  • If any one answered this i will give brilientst what is stimulation program​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!