Sort using algorithm header

The below program takes an array as input and prints the sorted array. The header <algorithm> defines a collection of functions especially designed to be used on ranges of elements.sort function takes two arguments. The arguments are the start index and end index of array. This header file does not work in c. It can be only used in C++.

Output : 

Code :

using namespace std;

int main()
int n;
cout<<"Enter number of elements you want to sort : ";
int a[n];
for(int i=0;i<n;i++)
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
return 0;


Related posts

Leave a Comment