Advertisement
noor017

Character Sorting

Jun 6th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.49 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main ()
  4. {
  5.     char array[100], temp;
  6.     int i, j, size;
  7.  
  8.     printf("Enter a word: ");
  9.  
  10.     scanf("%s", array);
  11.     size = strlen(array);
  12.  
  13.     for (i=0; i<size-1; i++)
  14.     {
  15.         for (j=i+1; j<size; j++)
  16.         {
  17.             if (array[i] > array[j])
  18.             {
  19.                 temp = array[i];
  20.                 array[i] = array[j];
  21.                 array[j] = temp;
  22.             }
  23.         }
  24.     }
  25.     printf("Sorting: %s\n", array);
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement