Looking for vowels, characters, etc. in a few strings

I have to write a program which outputs how many characters (letters+spaces), vowels, consonants, and words there are.

The following code is my first attempt at doing this (sorry if its a little long):

for(int i=0; i<5; i++)
{ getline(cin, sentence[i]);
total_length+=sentence[i].length();
}


for(int i=0; i<5; i++)
{ for(int j=0; j<sentence[i].length(); i++)
{ for(int k=0; k<10; k++)
if(sentence[i][j]==vowels[k])
vowel_counter++;
if(sentence[i][j]==' ')
word_counter++;
}
}

for(char letter='B'; letter<'z'; letter++)
{ for(int i=0; i<10; i++)
if(letter==vowels[i])
{ letter++;
break;
}

if(letter>'Z' && letter<'a')
flag=1;
if(letter=='a')
flag=0;

for(int i=0; i<5; i++)
{ for(int j=0; j<sentence[i].length(); i++)
{ if(sentence[i][j]==letter && flag==0)
consonant_counter++;
if(sentence[i][j]==letter && flag==1)
total_length--;
}
}
}

and then i output the info.
You didn't ask a question. Does your code compile? Does it give correct output? Are you just looking for suggestions on coding style?
Oh, sorry.
I guess im just tired because there are a few really careless mistakes, overall I think i have the problem covered.
Last edited on
Topic archived. No new replies allowed.