Guest
Posts: n/a

 03-11-2006
I wanted to write a code to calculate the number of words containing
vowels in a given set....if you find the error please reply at
http://www.velocityreviews.com/forums/(E-Mail Removed)

# include <iostream>
using namespace std;

int main ()
{
char input;
float vowel = 0; float words = -1;
float percent;
for ( ; cin >> input ; )
{ //if ( input == '.' ) {break;}
//if ( input == ' ') { words ++; continue ;}
if ( input == 'a' || input == 'e' || input == 'i' || input == 'o'
|| input =='u')
{ vowel ++; }
if ( input == '.') {break;}
if ( input != 'a' || input != 'e' || input != 'i' || input !=
'o' || input !='u')
{ continue; }
}
cout << words << " " << vowel ;

percent = (vowel/words) * 100;
cout << endl <<percent;

int i ;
cin >> i;
return 0;
}

Moonlit
Guest
Posts: n/a

 03-11-2006
Hi,

if ( input != 'a' || input != 'e' || input != 'i' || input !=
'o' || input !='u')
{ continue; }
}

Now look at that line closely when will the condition be false?

--

Regards, Ron AF Greve

http://moonlit.xs4all.nl

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>I wanted to write a code to calculate the number of words containing
> vowels in a given set....if you find the error please reply at
> (E-Mail Removed)
>
> # include <iostream>
> using namespace std;
>
> int main ()
> {
> char input;
> float vowel = 0; float words = -1;
> float percent;
> for ( ; cin >> input ; )
> { //if ( input == '.' ) {break;}
> //if ( input == ' ') { words ++; continue ;}
> if ( input == 'a' || input == 'e' || input == 'i' || input == 'o'
> || input =='u')
> { vowel ++; }
> if ( input == '.') {break;}
> if ( input != 'a' || input != 'e' || input != 'i' || input !=
> 'o' || input !='u')
> { continue; }
> }
> cout << words << " " << vowel ;
>
> percent = (vowel/words) * 100;
> cout << endl <<percent;
>
> int i ;
> cin >> i;
> return 0;
> }
>

Ivan Vecerina
Guest
Posts: n/a

 03-11-2006
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
:I wanted to write a code to calculate the number of words containing
: vowels in a given set....if you find the error please reply at
: (E-Mail Removed)

It is against this newsgroup's policy to provide answers by email.

You seem to be counting vowels instead of counting words that contain
vowels. You could try to set a flag (bool hasVowel) whenever a vowel
is encountered, then when the end of a word has been found:
{ ++words; if(hasVowel) { ++vowelWords; hasVowel=false; } }

Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com

Moonlit
Guest
Posts: n/a

 03-11-2006
Besides that.

To make your life (assignment) eassier look into string and
string.find_first_of:

http://www.sgi.com/tech/stl/basic_string.html

don't forget to include <string>

--

Regards, Ron AF Greve

http://moonlit.xs4all.nl

"Moonlit" <news moonlit xs4all nl> wrote in message
news:4412cf35\$0\$11064\$(E-Mail Removed)4all.nl...
> Hi,
>
> if ( input != 'a' || input != 'e' || input != 'i' || input !=
> 'o' || input !='u')
> { continue; }
> }
>
>
> Now look at that line closely when will the condition be false?
>
> --
>
>
> Regards, Ron AF Greve
>
> http://moonlit.xs4all.nl
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
>>I wanted to write a code to calculate the number of words containing
>> vowels in a given set....if you find the error please reply at
>> (E-Mail Removed)
>>
>> # include <iostream>
>> using namespace std;
>>
>> int main ()
>> {
>> char input;
>> float vowel = 0; float words = -1;
>> float percent;
>> for ( ; cin >> input ; )
>> { //if ( input == '.' ) {break;}
>> //if ( input == ' ') { words ++; continue ;}
>> if ( input == 'a' || input == 'e' || input == 'i' || input == 'o'
>> || input =='u')
>> { vowel ++; }
>> if ( input == '.') {break;}
>> if ( input != 'a' || input != 'e' || input != 'i' || input !=
>> 'o' || input !='u')
>> { continue; }
>> }
>> cout << words << " " << vowel ;
>>
>> percent = (vowel/words) * 100;
>> cout << endl <<percent;
>>
>> int i ;
>> cin >> i;
>> return 0;
>> }
>>

>
>

osmium
Guest
Posts: n/a

 03-11-2006
<(E-Mail Removed)> wrote:

>I wanted to write a code to calculate the number of words containing
> vowels in a given set....if you find the error please reply at

I know of only one possible word in English that has no vowel. Many people
claim that ms is a word; if you buy into that notion I don't) , the fraction
is 1/ number of words in the English language.

Moonlit
Guest
Posts: n/a

 03-11-2006

--

"osmium" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> <(E-Mail Removed)> wrote:
>
>>I wanted to write a code to calculate the number of words containing
>> vowels in a given set....if you find the error please reply at

>
> I know of only one possible word in English that has no vowel. Many people
> claim that ms is a word; if you buy into that notion I don't)

Lol, good one
> , the fraction is 1/ number of words in the English language.
>
>
>

Regards, Ron AF Greve

http://moonlit.xs4all.nl

Andrew Koenig
Guest
Posts: n/a

 03-11-2006
"osmium" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

> I know of only one possible word in English that has no vowel.

crwth: A bowed Welsh lyre played from the European Middle Ages to about
1800. It was about the size of a violin. Though originally plucked, it was
played with a bow from the 11th century, and a fingerboard was added behind
the strings in the last part of the 13th century.

Phlip
Guest
Posts: n/a

 03-11-2006
Andrew Koenig wrote:

>> I know of only one possible word in English that has no vowel.

>
> crwth: A bowed Welsh lyre played from the European Middle Ages to about
> 1800. It was about the size of a violin. Though originally plucked, it was
> played with a bow from the 11th century, and a fingerboard was added
> behind the strings in the last part of the 13th century.

The vowels are AEIOU, sometimes Y and sometimes W.

You will also find "cwm", which is a variation of "coomb", a steep valley
high in the mountains. (Cf Tolkien's Deeping Coomb.)

I once slaughtered a 6th-grade class in Hangman with that one.

--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!

Ivan Vecerina
Guest
Posts: n/a

 03-11-2006
"Phlip" <(E-Mail Removed)> wrote in message
news:vIDQf.19651\$(E-Mail Removed) om...
: Andrew Koenig wrote:
:
: >> I know of only one possible word in English that has no vowel.
: >
: > crwth: A bowed Welsh lyre played from the European Middle Ages to
: > 1800. It was about the size of a violin. Though originally plucked, it
was
: > played with a bow from the 11th century, and a fingerboard was added
: > behind the strings in the last part of the 13th century.
:
: The vowels are AEIOU, sometimes Y and sometimes W.

The OP did not specify that the words were in English.
In some slavic languages, e.g. Croatian, R is used
as a vowel, leading to words such as prst (finger)
or stvrdnuti (solidify) -- which I find cute.

Even in English, many abbreviations and acronyms have
made it into the dictionary ( mph, mm, ccw... ), and
definitely could be found in a source text.

--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form

Len Philpot
Guest
Posts: n/a

 03-11-2006
Andrew Koenig said the following on 3/11/2006 11:19 AM:
> "osmium" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>> I know of only one possible word in English that has no vowel.

>
> crwth: A bowed Welsh lyre played from the European Middle Ages to about
> 1800. It was about the size of a violin. Though originally plucked, it was
> played with a bow from the 11th century, and a fingerboard was added behind
> the strings in the last part of the 13th century.

Then again, with names like
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysilio gogogoch, does Welsh
actually qualify as English? (or American, for that matter

I grant you there are some vowels in there, if you search diligently
enough... Although as a single language American, I'm in no position to
question things I suppose. Like the old joke goes :

Q. What do you call a German who also speaks French & Italian fluently?
A. Multi-lingual

Q. What do you call a man who speaks Spanish & Portugese fluently?
A. Bi-lingual

Q. What you do call a man who speaks English poorly?
A. An American

--

---- Len Philpot -------- (E-Mail Removed)
------- ><> ------------- http://members.cox.net/lenphilpot/