Please help!!!!

S

siddhartha.chadha

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 address 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;
}
 
M

Moonlit

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
 
I

Ivan Vecerina

: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 address 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
 
O

osmium

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.
 
M

Moonlit

--



osmium said:
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
 
A

Andrew Koenig

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.
 
P

Phlip

Andrew said:
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. ;-)
 
I

Ivan Vecerina

: 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.


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.
 
L

Len Philpot

Andrew Koenig said the following on 3/11/2006 11:19 AM:
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
Llanfairpwllgwyngyllgogerychwyrndrobwllllantysiliogogogoch, 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

:)
 
O

osmium

Andrew Koenig said:
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.

Remarkable! So I had a hundred percent error in my post, there are *two*
words. I looked it up in my unabridged MW 3rd edition, and there it was! I
have never heard, until today, of the escape rules for 'W' mentioned
up-thread.
 
P

Phlip

osmium said:
Remarkable! So I had a hundred percent error in my post, there are *two*
words. I looked it up in my unabridged MW 3rd edition, and there it was!
I
have never heard, until today, of the escape rules for 'W' mentioned
up-thread.

If you mean my rules, I made them up. (-;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top