Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <stdlib.h>
#include <stdio.h>
int main()
{
int m[5]={2, 8, 6, 5, 1};
int i = 1, j, c;
while (i < 5) {
j = 0;
while (j < i) {
if (m[j] > m[i]) {
c = m[j];
m[j] = m[i];
m[i] = c;
}
j++;
}
i++;
}
printf("m[0] = %d\n", m[0]);
printf("m[1] = %d\n", m[1]);
printf("m[2] = %d\n", m[2]);
printf("m[3] = %d\n", m[3]);
printf("m[4] = %d\n", m[4]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment