Get Website Learn Coding Tech Story

C Programming Examples

#include<stdio.h>

int main() {
	int data[10], i, j, temp;
	printf("Enter 10 random number to sort in ascending order:\n");
	for(i = 0; i < 10; i++)
		scanf("%d", &data[i]);

	/* Sorting process start */
	for(i = 0; i < 10; i++) {
		for(j = i+1; j < 10; j++) {
			if(data[j] < data[i]) {
				temp = data[i];
				data[i] = data[j];
				data[j] = temp;
			}
		}
	}
	printf("After sort\n");
	for(i = 0; i < 10; i++)
		printf("%d\n",data[i]);
	return 0;
}


          /****** Output ******/
          

Enter 10 random number to sort in ascending order:


4


6


1


8


3


7


2


5


9


0



After sort


0


1


2


3


4


5


6


7


8


9

Learn more about Bubble Sort