sahajjain01

04.Sort the given array using Selection Sort.

Aug 15th, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.44 KB | None | 0 0
  1. //Program to sort the given array using Selection Sort.
  2. #include <stdio.h>
  3. #include <conio.h>
  4.  
  5. void main () {
  6.     int i, j, temp,
  7.     arr[10] = {
  8.         1, 23, 55, 2, 26, 66, 87, 21, 88, 54
  9.     };
  10.  
  11.     clrscr ();
  12.  
  13.     for (i = 0; i < 10; i++) {
  14.         for (j = i + 1; j < 10; j++) {
  15.             if (arr[j] < arr[i]) {
  16.                 temp = arr[i];
  17.                 arr[i] = arr[j];
  18.                 arr[j] = temp;
  19.             }
  20.         }
  21.     }
  22.  
  23.     for (i = 0; i < 10; i++) {
  24.         printf ("%d\n", arr[i]);
  25.     }
  26.  
  27.     getch ();
  28. }
Add Comment
Please, Sign In to add comment