Skip to content

Instantly share code, notes, and snippets.

@fariedrahmat
Created December 13, 2025 23:56
Show Gist options
  • Select an option

  • Save fariedrahmat/92a028bfac20a72564ac3cf90abed2bf to your computer and use it in GitHub Desktop.

Select an option

Save fariedrahmat/92a028bfac20a72564ac3cf90abed2bf to your computer and use it in GitHub Desktop.
Sorting Angka Kecil Ke besar
#include <stdio.h>
void sorting(int arr[], int n) {
int temp;
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
if (arr[j] > arr[j + 1]) {
temp = arr[j];
arr[j] = arr[j + 1];
arr[j + 1] = temp;
}
}
}
}
int main() {
int data[] = {6, 5, 4, 3, 2, 1};
int n = sizeof(data) / sizeof(data[0]);
sorting(data, n);
for (int i = 0; i < n; i++) {
printf("%d ", data[i]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment