answersLogoWhite

0


Best Answer

FILE *fPtr = fopen("ConsonantInput.txt", "r");

char sWord[1024];

int nWordCount = 0;

while(!feof(fPtr))

{

memset(sWord, 0x00, sizeof(sWord));

fscanf(fPtr, "%s", sWord);

short nCount = strlen(sWord);

short nConsonantCount = 0;

for(int i = 0; i < nCount; ++i)

{

switch(sWord[1])

{

case 'A':

case 'E':

case 'I':

case 'O':

case 'U':

case 'a':

case 'e':

case 'i':

case 'o':

case 'u':

case '-':

{

break;

}

default:

++nConsonantCount;

}

if(nConsonantCount >= MAX_CONSONANT_NUMBER)

{

++nWordCount;

break;

}

}

}

printf("Number of Words : %d, Time Taken : %.2f", nWordCount);

fclose(fPtr);

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can you write a c program to count the number of words with not more than 5 consonants in a text file?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Program to count the number of characters and words in the line?

in linux wc -l filename will count the lines and wc will count the letters


What words have double consonants bb in the middle?

consonants with BB


What words have consonants in them?

Words that have consonants in them are most commonly the words that do not have all vowels. Some examples of such words are &quot;cat,&quot; &quot;dog,&quot; &quot;book,&quot; and &quot;can.&quot;


How many words with or without meaning each of 2 vowels and 3 consonants can be formed from the letters of the word DAUGHTER?

In the word DAUGHTER, there are 3 vowels namely, A, U, and E, and 5 consonants namely, D, G, H, T, and R. Number of ways of selecting 2 vowels out of 3 vowels = Number of ways of selecting 3 consonants out of 5 consonants = Therefore, number of combinations of 2 vowels and 3 consonants = 3 &times; 10 = 30 Each of these 30 combinations of 2 vowels and 3 consonants can be arranged among themselves in 5! ways. Hence, required number of different words = 30 &times; 5! = 3600


Examples of double consonants?

Some words with double consonants are rattle, tattle, cattle, battle, mitten, kitten (the tt in the middle of the word is an example of double consonants)Other words with double consonants are rubble, dabble, ribbed, dabbing (the bb in the middle of the word is an example of double consonants.


What are some words start and end with consonants?

Please refer to the related questions for some words start and end with consonants.


How many three letter words contain only consonants?

There are no three letter words that contain only consonants. They need vowels.Y is used as a vowel but not a real vowel; you may try: cry, dry, fry, ply, fly, shy, why, or sly.


Is the word unload a vowel or consonant?

The word unload is a verb. Words are not consonants or vowels, words have consonants and vowels. unload has 3 vowels (u,o,a) and 3 consonants (n,l,d)


What number words have two vowels and three constanants?

The number 7/seven, it has two vowels and three consonants....... thats the answer I see best for your question........


What is summing the number of words in a document?

Word Count


What words has 2 consonants next to each other?

You have written 6 of them in your question - what, words, consonants, next, each, other I hope this helps


What words can have double or single consonants in then?

alot