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
This describes what is charted. It can be placed above or below the chart.
Tems11 [23]

Answer:

a . chart area

This describes what is charted. It can be placed above or below the chart.

Explanation:

3 0
2 years ago
What is the best application to create a slide show presentation?
Lynna [10]

Answer:

Microsoft Windows File Manager

5 0
3 years ago
Read 2 more answers
Text box linking is for two or more text boxes in a document, when the text overflows from the first box. Which scenario is the
Julli [10]

Answer:

Explanation:

use the next box i think

8 0
2 years ago
Read 2 more answers
A corporate user is attempting to connect to the company’s Windows domain server on the local network with her new laptop throug
andreev551 [17]

Answer:

B. Windows domain user name and password

Explanation:

Windows domain user name and password are login credentials required for the user to successfully sign in to the Windows domain.

The domain username and password are usually stored on a domain controller rather than on the host.

As a domain user, the computer seeks from the domain controller the privileges assigned to the user, if it gets a positive response from the domain controller, it authorizes the users login credentials without restrictions; else, it denies the user access.

8 0
3 years ago
2 reasons why someone might want to alter data on someone else’s computer
IRINA_888 [86]

Answer:

1. Looking at someone else's files.

2. To hack into the bank's computer and wanting to increase the amount in your account.

6 0
3 years ago
Other questions:
  • What type of elements are bridges exposed to yearly
    13·2 answers
  • Para saan po yung points dito?
    15·1 answer
  • What considerations have to be kept in mind with JPEG
    10·1 answer
  • Which of the following are benefits of designing a scalable system? Choose 3 options.
    15·1 answer
  • You are called to assist in troubleshooting a network problem that has occurred soon after a significant IPv6 implementation. So
    11·1 answer
  • A high school in a low-income area offers special programs to help students acquire the technical skills needed to find jobs as
    12·1 answer
  • Which type of loan is based on financial need
    6·1 answer
  • How does links helped a student like you in navigating the different available websites?
    5·1 answer
  • What are five don’ts of using a computer
    8·2 answers
  • Is Using programming libraries is one way of incorporating existing code into new programs true
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!