Computer Science, asked by piyali, 1 year ago

write a program to count the number of vowels and consonants from a given text field?

Answers

Answered by Joydeep21
1
int vowelcount = 0,concount = c;
string str = new String(Tf1.getText());
int len = Str.getText();
for(int = 0;i<=len-1;i++)
{
char ch = str.charAt(i);
if (ch =='a' or ch=='e' or ch=='i' or ch=='o' or ch=='u')
{
vowelcount++;
}
else
{
conscount++;
}
}
Tf1.setText(" "+vowelcount);
}
Answered by kvnmurty
1
In c language
int  vowels = consonants = 0 ;    char ch;
while ( (ch = getchar () ) != NULL) {
       if ( ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' )
           vowels ++ ;
       else    consonants ++;
}
printf ("consonants :  %d  vowels : %d \n", consonants, vowels);

Similar questions