Coders Packet

C++ Program to Sort Elements of Array in Ascending Order/Increasing Order

By Ashish Kumar Gupta

This is a C++ Program to Sort Elements of an Array in Ascending Order/Increasing Order with the help of the sort() function, we are going to execute this program

Algorithm Explanation:

1. First we took an Array of Five-element. 

 

2.  Creating a Variable "n" to store the size of the Array.

 

3. The sort() function takes as input the first and the last element of the Array. This function makes a comparison in a way that puts all the elements in Ascending Order/Increasing Order.

4. After sorting we print the element with the help of a loop.

INPUT:

3,6,2,4,5

OUTPUT:

2,3,4,5,6

Time Complexity :O(nlogn).

 

Download Complete Code

Comments

No comments yet