Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program to sort the given array using Insertion 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 = 1; i < 10; i++) {
- j = i;
- while (j > 0 && arr[j] < arr[j-1]) {
- temp = arr[j];
- arr[j] = arr[j-1];
- arr[j-1] = temp;
- j--;
- }
- }
- for (i = 0; i < 10; i++) {
- printf("%d\n", arr[i]);
- }
- getch();
- }
Add Comment
Please, Sign In to add comment