Hello **Programmers/Coders,** Today we are going to share ** solutions of Programming problems of HackerRank of Programming Language C++ **. At Each Problem with Successful submission with

**all Test Cases Passed,**you will get an score or marks. And after solving maximum problems, you will be getting stars. This will highlight you profile to the recruiters.

In this post, you will find the solution for **Vector-Sort in C++-HackerRank Problem**. We are providing the **correct and tested solutions** of coding problems present on **HackerRank**. If you are not able to solve any problem, then you can take help from our Blog/website.

Use “Ctrl+F” To Find Any Questions Answer. & For Mobile User, You Just Need To Click On Three dots In Your Browser & You Will Get A “Find” Option There. Use These Option to Get Any Random Questions Answer.

**Introduction To C++**

**C++** is a general-purpose programming language that was developed as an enhancement of the C language to include object-oriented paradigm. It is an imperative and a **compiled** language.

C++ is a middle-level language rendering it the advantage of programming low-level (drivers, kernels) and even higher-level applications (games, GUI, desktop apps etc.). The basic syntax and code structure of both C and C++ are the same.

**C++ programming language was developed in 1980 by Bjarne Stroustrup at bell laboratories of AT&T (American Telephone & Telegraph), located in U.S.A. Bjarne Stroustrup is known as the founder of C++ language.**

Vector-Sort in C++ – Hacker Rank Solution

# Problem

You are given * N* integers. Sort the

*integers and print the sorted order.*

**N**Store the

*integers in a vector. Vectors are sequence containers representing arrays that can change in size.*

**N****Declaration :**

vector<int>v; (creates an empty vector of integers)

**Size :**

intsize=v.size();

**Pushing an integer into a vector :**

v.push_back(x);(where x is an integer.The size increases by1afterthis.)

**Popping the last element from the vector :**

v.pop_back(); (Afterthisthe size decreases by1)

**Sorting a vector :**

sort(v.begin(),v.end()); (Will sort all the elements in the vector)

### Input Format :

The first line of the input contains * N* where

*is the number of integers. The next line contains*

**N***integers.*

**N**### Constraints :

- 1 <= N <= 10^5
- 1<= Vi <= 10^9, where Vi is the ith integer in the Vertex

### Output Format :

Print the integers in the sorted order one by one in a single line followed by a space.

### Sample Input :

5161084

### Sample Output :

146810

Vector-Sort in C++ – Hacker Rank Solution

#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { /* Vector-Sort in C++ - Hacker Rank Solution Start */ int n,i; cin >> n; vector<int> numbers(n, 0); for(i = 0; i < n; i++) { cin >> numbers[i]; } sort(numbers.begin(), numbers.end()); for(i = 0; i < n; i++) { cout << numbers[i] << " "; } /* Vector-Sort in C++ - Hacker Rank Solution End */ return 0; }