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
_____________ describes the abstraction of web-based computers, resources, and services that system developers can utilize to im
Vika [28.1K]

Answer:

c. Cloud computing

Explanation:

Cloud computing -

It refers to the on - time need of the computer resource , in order to store data , computing power by the user , is referred to as cloud computing.

It refers to the availability of the data centers to the user .

This method enables the sharing of resources .

Hence, from the information of the question,

The correct option is c. Cloud computing .

6 0
3 years ago
In pre-shared key mode, a passphrase should be at least ________ characters long.
alexandr402 [8]
10.......................................

8 0
2 years ago
What is the difference between second generation and third generation of computer​
Alexeev081 [22]

Answer:

The main difference between second generation (2G) and third generation (3G) technology is data. 2G services were developed with mostly voice services in mind, but are capable of providing relatively slow (14.4kbps) speed data services.

8 0
2 years ago
Question 7<br> What is the description of The Ribbon?
Aloiza [94]

Answer:

a flat or tubular narrow closely woven fabric (as of silk or rayon) used for trimmings or knitting. b : a narrow fabric used for tying packages. c : a piece of usually multicolored ribbon worn as a military decoration or in place of a medal. d : a strip of colored satin given for winning a place in a competition

7 0
2 years ago
Proponents of Internet freedom see its _____________ as providing protection for unpopular expression; proponents of greater Int
NeTakaya

Answer: The answer is anonymity

Explanation: i had the same question on my test.

8 0
2 years ago
Other questions:
  • System memory is on a computer motherboard?
    14·2 answers
  • To check whether your writing is clear , you can
    15·2 answers
  • What processes are needed to transform a c++ program to a machine language program that is ready for execution?
    14·1 answer
  • In which of the following situations will a macro make your work more efficient?
    9·1 answer
  • After modifying the font of the Subheading1 style, you notice that the font of Subheading2 has also changed. What is the most li
    12·2 answers
  • What is the term used when a password is obtained through tricking a user into giving it to another party?
    15·1 answer
  • Which role involves designing and creating advertisements for marketing purposes?
    14·2 answers
  • Pleaseeeeeeee tellllllllllllllllllllll​
    8·1 answer
  • If Anime Characters were real , Who Would Your Anime Wife Would Be (Tell Who And Why)
    10·1 answer
  • You text file begins with the following rows. The pattern is a description of the item to be repaired, its color, and the issue.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!