jae-l
5/30/2017 - 6:49 PM

Example of using else if statements to find if a character is a vowel or consonant.

Example of using else if statements to find if a character is a vowel or consonant.

Console.Write("Enter a letter: ");
char c = Char.Parse(Console.ReadLine());

if (c == 'A' || c == 'a')
{
  Console.WriteLine("Vowel [ei]");
}
else if (c == 'E' || c == 'e')
{
  Console.WriteLine("Vowel [i:]");
}
else if (c == 'I' || c == 'i')
{
  Console.WriteLine("Vowel [ai]");
}
else if (c == 'O' || c == 'o')
{
Console.WriteLine("Vowel [ou]");
}
else if (c == 'U' || c == 'u')
{
  Console.WriteLine("Vowel [ju:]");
}
else
{
  Console.WriteLine("Consonant");
}

//  Enter a letter: j
//  Consonant