#include<stdio.h> #include<math.h> #include<stdbool.h> void main() { int a[20]; int j, i, k, h, save; i = -1; do { i++; printf("enter value a %d = ", i + 1); scanf("%d", &a[i]); }while(a[i] >= 0); for (k = 0; k < i - 1; k++) { for (h =k + 1; h < i; h++) { if(a[k]>a[h]) { save = a[k]; a[k] = a[h]; a[h] = save; } } } printf("a = "); for ( j = 0; j < i; j++ ) printf("%d\t", a[j]); getch(); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter