#include <iostream>
#include <algorithm>
using namespace std;
int main(){
//declare and define an array
int arr[]={10, 1, 20, 2, 30};
//size of the array
//total size/size of an element
int size = sizeof(arr)/sizeof(int);
//calling sort() to sort array elements
sort(arr, arr+5, greater<>());
//printing sorted elements
cout<<"Sorted elements are: ";
for(int i=0; i<size; i++)
cout<<arr[i]<<" ";
return 0;
}
C++ program:
Output