/* Arrays used to store vowel and consonant letters * found in the input word without repetitions */ char wordVowels[6] = {0}; char wordConsonants[20] = {0};
/* The numbers of different vowels and consonants found in this word */ int vowelCount = 0; int consonantCount = 0;
register char letter; register int isVowel;
/* Get a sequence of characters from user */ printf("Enter a word:\n"); gets(word); putchar('\n');
for (int c = 0; word[c]; c++) { /* Check if current character is a letter */ letter = tolower(word[c]); if (!isalpha(word[c])) { printf("Wrong character: %c\n", letter); continue; }
/* Check if it's a vowel */ isVowel = (int)strchr(VOWELS, letter);
/* Add it to array of vowels or to array of consonants */ if (isVowel && !strchr(wordVowels, letter)) { wordVowels[vowelCount] = letter; vowelCount++; }
/* Output vowels found in the input word */ printf("Vowels met in this word:\n"); for (int v = 0; v < vowelCount; v++) printf("& %c", wordVowels[v]); printf("\n\n");
/* Output consonants found in the input word */ printf("Consonants met in this word:\n"); for (int c = 0; c < consonantCount; c++) printf("& %c", wordConsonants[c]);
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment