└── sorting /sorting: -------------------------------------------------------------------------------- 1 | #include 2 | void main (){ 3 | int num[20]; 4 | int i, j, a, n; 5 | printf("enter number of elements in an array"); 6 | scanf("%d", &n); 7 | printf("Enter the elements"); 8 | for (i = 0; i < n; ++i) 9 | scanf("%d", &num[i]); 10 | for (i = 0; i < n; ++i){ 11 | for (j = i + 1; j < n; ++j){ 12 | if (num[i] > num[j]){ 13 | a = num[i]; 14 | num[i] = num[j]; 15 | num[j] = a; 16 | } 17 | } 18 | } 19 | printf("The numbers in ascending order is:"); 20 | for (i = 0; i < n; ++i){ 21 | printf("%d", num[i]); 22 | } 23 | } 24 | --------------------------------------------------------------------------------