Created
December 13, 2025 23:56
-
-
Save fariedrahmat/92a028bfac20a72564ac3cf90abed2bf to your computer and use it in GitHub Desktop.
Sorting Angka Kecil Ke besar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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