Write a function to sort an array consists
of 10 integer numbers in descending order,
print the array before sorting and after
sorting.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int arr[10] = {3,2,4,5,6,7,2,0,8,4};
cout << "Before reversing the array:\n";
for (int i = 0; i < 10; i++) {
cout << arr[i] << ' ';
}
cout << '\n';
cout << "Agter reversing the array:\n";
sort(arr, arr+10);
reverse(arr, arr+10);
for (int i = 0; i < 10; i++) {
cout << arr[i] << ' ';
}
}
Comments
Leave a comment