![]() |
Number of consonants
Help me please! I want to make a program that displays the word with the maximum number of consonants from a sentence.
|
Re: Number of consonants
How far have you got and where are you stuck?
Can you create a program as a start that just displays individual words? After that you can count the number of consonants in each word and store (a) the number if it's the largest so far and (b) the word itself. At the end just display the word that you stored before. Possible algorithm: count=0; word="" for each word consonant count > count? yes: assign count and word end for display word. |
Re: Number of consonants
Here is a variant of my program, please help me find the mistake.
Code:
#include <stdio.h> |
Re: Number of consonants
I'm not surprised you can't debug that code; it's a horrendous mess. Use meaningful variable names, indent code correctly, and use code tags when posting here. You can identify code problems by adding printf statements to it that display intermediate results, for instance as I hinted you could try displaying words as you pull them out of the sentence, then display the consonant count and if it's greater than the previous greatest; these should all help you find the problems.
Why is it "a variant on your program" and not your program itself? Did you find this example online instead of writing it yourself? |
Re: Number of consonants
Your if statement contains an assignment. You probably wanted to do a comparison.
|
Re: Number of consonants
Of course I wroted myself, if I had found it on the internet it would be correct.
|
Re: Number of consonants
Quote:
|
Re: Number of consonants
Quote:
|
Re: Number of consonants
Quote:
|
Re: Number of consonants
A little help please!:shy:
|
| All times are GMT +5.5. The time now is 12:06. |