selection sort algorithm

it keeps saying that 'error expected initializer before 'void'

how can i make it work? and how can i let it sort an array of 10 elements type integer?



#include <iostream>
using namespace std;
int main()

void selectionSort(int arr[], int n);
{
int i, j, minIndex, temp;

for (i = 0; i < n-1; j++)
if (arr[j] < arr[minIndex])
minIndex = j;

if (minIndex != i)
{temp = arr [i];
arr[i] = arr[minIndex];
arr[minIndex] = temp;
}
return 0;
}
You need to implement main:
1
2
3
4
5
6
7
int main()
{
  int arr[] = { 4, 6, 1, 7 };
  selectionSort(arr, 4);

  return 0;
}
Topic archived. No new replies allowed.