SHARE
TWEET

Untitled

a guest Sep 15th, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <string.h>
  3. void main () {
  4.     int i, j, n;
  5.     printf("Enter the number of words you want to arrange in alphabetical order: ");
  6.     scanf("%d", &n);
  7.     char a[n][100], temp[n][100], new[n][100];
  8.     printf("Enter the words:\n");
  9.     for(i = 0; i < n; i++) {
  10.         for(j = 0; j < 1; j++) {
  11.             printf("%d) ", i+1);
  12.             scanf("%s", a[i]);
  13.             if(a[i][j] >= 65 && a[i][j] <= 90) {
  14.                 strlwr(a[i]);
  15.             }
  16.         }
  17.     }
  18.     for(i = 0; i < n; i++) {
  19.         for(j = 0; j < 2; j++) {
  20.             if(strcmp(a[j], a[i]) > 0) {
  21.                 strcpy(temp[i], a[j]);
  22.                 strcpy(a[j], a[i]);
  23.                 strcpy(a[i], temp[i]);
  24.                
  25.             }
  26.         }
  27.     }
  28.     printf("=====Aplhabetical Order!=====\n");
  29.     for(i = 0; i < n; i++) {
  30.         for(j = 0; j < 1; j++) {
  31.             printf("%s\n", a[i]);
  32.         }
  33.            }
  34.     printf("=============================");
  35.  
  36.    
  37.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top