Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- void main () {
- int i, j, n;
- printf("Enter the number of words you want to arrange in alphabetical order: ");
- scanf("%d", &n);
- char a[n][100], temp[n][100], new[n][100];
- printf("Enter the words:\n");
- for(i = 0; i < n; i++) {
- for(j = 0; j < 1; j++) {
- printf("%d) ", i+1);
- scanf("%s", a[i]);
- if(a[i][j] >= 65 && a[i][j] <= 90) {
- strlwr(a[i]);
- }
- }
- }
- for(i = 0; i < n; i++) {
- for(j = 0; j < 2; j++) {
- if(strcmp(a[j], a[i]) > 0) {
- strcpy(temp[i], a[j]);
- strcpy(a[j], a[i]);
- strcpy(a[i], temp[i]);
- }
- }
- }
- printf("=====Aplhabetical Order!=====\n");
- for(i = 0; i < n; i++) {
- for(j = 0; j < 1; j++) {
- printf("%s\n", a[i]);
- }
- }
- printf("=============================");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement