## Description of turbo sort problem  This turbo sort problem is all about sorting a list of numbers. The user will give some numbers and we have to sort them in non-decreasing order. we can write the solution of this problem in different way and here we will see the probably best way to solve this problem.

The problem is taken from CodeChef for practice and learning purpose only. At first we will try to understand about the problem and go to code. So, let’s go ahead with coding.

## Solution to this turbo sort problem using C++

At first we will take the input from user that how many numbers he has for sorting. We will store all the numbers in an array and then we will apply a library function to sort them. This is very simple to use the sort() function which will take two parameters. One is the beginning of the array and other is the length up to which we want to sort.

If a user gives the number of total number is 4.

Then 4 number is 5,  7,  3,  2

We have to sort them and print 2,  3,  5,  7

Here, we have to print each of them in a new line.

Now, let’s see the source code for turbo sort problem bellow;

``````// solving turbo sort problem

#include<iostream>
#include<bits/stdc++.h>
using namespace std;

int main(){
int Test;
scanf("%d", &Test);
int arr[Test];

for(int i = 0; i < Test; i++){
scanf("%d", &arr[i]);
}

sort(arr, arr+Test);

for(int i = 0; i < Test; i++){
printf("%d\n", arr[i]);
}

return 0;
}``````

When you compile and run the above program, you will get the output like this.

``````5
5
3
6
7
1
1
3
5
6
7``````

In this output screen, first line contains the number of total number which is 5. Then 5 line and each line has a single integer which we have to sort. The last five lines is the output of our program after sorting given numbers.

Previous pageC++ practice

Next pageSmall factorial

Recommended for you: