Selection Sort

The code for the selection sort in C lang is provided below.


#include
#define NUM 6

void swap(int arr[], int i, int j) {
int tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}

main() {

int arr[NUM],i,j;

// start reading nums
for(i=0;i arr[j])
swap(arr,i,j);

// print sorted arr
for(i=0;i

Please point your web link to this page if you are using this code for any purposes.

Leave a Reply

Your email address will not be published. Required fields are marked *