+ 1
Write a program to read a line of a text and print the number of character,vowels and consonant in the given line
2 ответов
+ 1
Void main ()
{
Int x,y;
Char st[50];
Cout<<"enter a string";
gets(st);
For(int i=1;st[i]!='\0';++i){
Switch(i)
{
case a:;
Case e:;
Case I:;
Case o:;
Case u:++x;break();
Default :++y;
}
Cout<<"total string"<<x+y;
Cout<<"total vovels"<<x;
Cout<<"total consonants"<<y;
}
+ 1
for vowels, I like to use an if ( c [ i ] == 'a' || c[ i ] == 'e' || // and so on) you could then just count the consonants in the else statement. I could write out the code of you need. Also, this answer above won't count the first two characters in the array due to the fact that his i in the for loop starts at 1 and not 0, and then it is incremented first (++i) before evaluation. he should have for ( int i = 0; st[ i ] != '\0'; i++)