#include void main () { int i, j, tmp, length; printf("Please input the length of array which you want to sort.\n"); scanf("%d", &length); int a[length]; /* input the elements of the array */ printf("Please input the elements of array one by one\n"); for (i=0; i< length; i++) { scanf("%d", &a[i]); } /* output the unsorted array */ printf("The array is: "); for(i=0;i a[j]) { /* switch a[i] and a[j] */ tmp = a[i]; a[i] = a[j]; a[j] = tmp; } } } /* output the sorted array */ printf("The sorted array is: "); for (i=0; i < length; i++) { printf("%d, ", a[i]); } printf("\n"); }