using System;
class HelloWorld {
static void Main() {
HelloWorld hw = new HelloWorld();
hw.CountVovelAndConsonant('I know you it ');
}
void CountVovelAndConsonant(string str){
int noVowel=0, noConsonant=0;
char[] charArray = str.ToCharArray();
foreach(char ch in charArray){
if (ch == ' ')
continue;
else if(IsVowel(ch))
noVovel++;
else
noConsonant++;
}
Console.WriteLine('No of Vowel {0} and No of Consonant {1}',noVowel, noConsonant);
}
bool IsVowel(char ch){
switch(Char.ToLower(ch)){
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
return true;
default:
return false;
}
}
}
Output
No of Vowel 5 and No of Consonant 5
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
Program
Output
No of Vowel 5 and No of Consonant 5