write a program to count the number of vowels and consonants from a given text field?
Answers
Answered by
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);
}
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
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);
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