/* Program that places input words in alphabetic order. */ #include #include /* necessary for using any str... function */ main () { char word1[31], word2[31]; /* max length 30 each */ printf("Enter two words: "); scanf("%30s %30s", word1, word2); while (strcmp(word1, "END") != 0) { printf(" In order they are: "); if (strcmp(word1, word2) <= 0) { /* word1 belongs before, or is the same as, word2 */ printf("%s %s\n", word1, word2); } else { /* word2 belongs before word1 */ printf("%s %s (swapped)\n", word2, word1); } printf("Enter two words: "); /* prompt and... */ scanf("%30s %30s", word1, word2); /* get next two words */ } printf("Detected END word\n"); }