sort array c++
#include <iostream>
#include <algorithm>
int main() {
// Declare an array of integers
int arr[] = {5, 2, 8, 1, 6};
// Calculate the size of the array
int size = sizeof(arr) / sizeof(arr[0]);
// Use the sort function from the algorithm header to sort the array
std::sort(arr, arr + size);
// Display the sorted array
std::cout << "Sorted Array: ";
for (int i = 0; i < size; ++i) {
std::cout << arr[i] << " ";
}
return 0;
}