// Version 3

// meaningful identifier name
// avoid magic constants
// avoid generic variable

#include <stdio.h>

void main()
{
    int data[] = {12, 3, 37, 8, 24, 15, 5, 33};
    int ndata = sizeof(data) / sizeof(int);
    int i, j;
    int min;
    int swapTmp;
    
    i = 0;
    while (i<ndata)
    {
        min = i;
        j = i + 1;
        while (j<ndata)
        {
            if (data[j]<data[min]) min = j;
            j = j + 1;
        }
        swapTmp = data[min];
        data[min] = data[i];
        data[i] = swapTmp;
        i = i + 1;
    }
    
    printf("Sorted data:\n");
    i = 0;
    while (i<ndata)
    {
        printf(" %d", data[i]);
        i = i + 1;
    }
    printf("\n");
}