Write a c++ program to print the selection sort

Write a c++ program to print the selection sort. This is also a sorting algorithm to arrange the element in the program in C++. Selection sorting means value is selected for every time to sort the values before sorting in selection sorting in c++ programming language.

#include <iostream>
using namespace std;
void swap(int *a, int *b) 
{
int temp = *a;
*a = *b;
*b = temp;
}
void array(int array[], int size)
{
for (int i = 0; i < size; i++) 
{
cout << array[i] << " ";
}
cout << endl;
}
void sort(int array[], int size) 
{
for (int step = 0; step < size - 1; step++)
{
int min_idx = step;
for (int i = step + 1; i < size; i++) 
{
if (array[i] < array[min_idx])
min_idx = i;
}
swap(&array[min_idx], &array[step]);
}
}
int main() 
{
int data[] = {45,576,34,57,23};
int size = sizeof(data) / sizeof(data[0]);
sort(data, size);
cout << "After sorting\n";
array(data, size);
}

Output:

After sorting 23 34 45 57 576