TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Monday, 24 August 2020

Sort In C++| Sort In C++ Program| Sort In C++ Example| Sort In C++ Syntax| Sort In C++ In Hindi

 

Sort In C++

C++ STL provides a similar function sort that sorts a vector or array (items with random access). sort() takes a third parameter that is used to specify the order in which elements are to be sorted.


image of Sort In C++

Fig:Sort In C++

Program:

#include <iostream.h>

#include<conio.h>

void main()

{

          int arr[] = {1, 5, 8, 9, 6, 7, 3, 4, 2, 0};

          int n = sizeof(arr)/sizeof(arr[0]);

          sort(arr, arr+n);

          cout << "\nArray after sorting using "

                   "default sort is : \n";

          for (int i = 0; i < n; ++i)

                   cout << arr[i] << " ";

getch();

}

 

Output:

Array after sorting using default sort is:

0,1,2,3,4,5,6,7,8,9

No comments:

Post a Comment