// An isogram is a word, in which no letter of the alphabet // occurs more than once. Write a C program that reads in // strings until Ctrl+D, and checks whether the string is an isogram. #include #include #include #define MAX 100 // Sample input/output // hello // This is not an isogram // table // This is an isogram // Yay // This is not an isogram // CtrlD int main(void) { char line[MAX]; while (fgets(line, MAX, stdin) != NULL) { // count the letters int letters[26] = {0}; int isogram = 1; int i = 0; while (line[i] != '\0') { if (isalpha(line[i])) { int index = tolower(line[i]) - 'a'; letters[index]++; if (letters[index] > 1) { isogram = 0; } } i++; } if (isogram == 0) { printf("This is not an isogram.\n"); } else { printf("This is an isogram.\n"); } } }