Q:

Write C# Program to check entered character vowel or consonant

0

Write C# Program to check entered character vowel or consonant.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.

using System;
 
public class charpexercise
{
    static void Main(string[] args)
    {
        char ch;
 
        Console.WriteLine("Enter any character: ");
        ch = Convert.ToChar(Console.ReadLine());
 
 
        // Condition for vowel checking
        if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')
        {
 
            Console.WriteLine(ch + " is Vowel.");
 
        }
        else if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
        {
            Console.WriteLine(ch + " is Consonant.");            
        }
 
        Console.ReadLine();
    }
}

Result:

Enter any character: 

a

a is Vowel.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write C# Program to check whether a character is a... >>
<< Write C# Program to check uppercase or lowercase a...