Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #define SIZE 6
- int main(void)
- {
- int bubble[] = { 95, 60, 6, 87, 50, 24 };
- int inner, outer, temp, x;
- /*Display original array */
- puts("Original Array: ");
- for(x = 0; x < SIZE; x++)
- printf("%d\t", bubble[x]);
- printf("\n\n");
- /*Bubble sort */
- for(outer = 0; outer < SIZE - 1; outer++)
- {
- for(inner = outer + 1; inner < SIZE; inner++)
- {
- if(bubble[outer] > bubble[inner])
- {
- temp = bubble[outer];
- bubble[outer] = bubble[inner];
- bubble[inner] = temp;
- }
- }
- }
- /*Display sorted array */
- puts("Sorted Array:");
- for(x = 0; x <SIZE; x++)
- printf("%d\t", bubble[x]);
- putchar('\n');
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement