Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program to sort the given array using Bubble Sort.
- #include <stdio.h>
- #include <conio.h>
- void main () {
- int i, j, temp,
- arr[10] = {
- 1, 23, 55, 2, 26, 66, 87, 21, 88, 54
- };
- clrscr ();
- for (i = 0; i < 10; i++) {
- for (j = 0; j < 10 - i; j++) {
- if (arr[j] > arr [j+1]) {
- temp = arr[j];
- arr[j] = arr[j+1];
- arr[j+1] = temp;
- }
- }
- }
- for (i = 0; i < 10; i++) {
- printf ("%d\n", arr[i]);
- }
- getch ();
- }
Add Comment
Please, Sign In to add comment