Write C# Program to check whether alphabet is vowel or consonant using if-else statement

Algorithm:-

(1)Start

(2)Take  character(alphabet) from user

(3)compare these character with all upper and lower case vowel

(4)if condition is true true then  print character is vowel else character is consonant

(5)stop

:-

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;



namespace VowelCheckFromChar_1_

{

    class Program

    {

        static void Main(string[] args)

        {

            char character;

            Console.WriteLine("enter an alphabet: ");

            character = char.Parse(Console.ReadLine());

            if ((character >= 'A' && character <= 'Z') || character >= 'a' && character <= 'z')

            {

                if (character == 'a' || character == 'A' || character == 'e' || character == 'E' || character == 'i'

                    || character == 'I' || character == 'o' || character == 'O' || character == 'u' || character == 'U')

                {

                    Console.WriteLine(character + " is a vowel");

                }

                else

                {

                    Console.WriteLine(character + " is a consonant");

                }

            }

            else

            {

                Console.WriteLine(character + " is not an alphabet");

            }


            Console.ReadKey();

        }

    }

}


Output:- enter an alphabet:a

a is a vowel

********************8

enter an alphabet:

v

v is a consonant

*****************************

Enter an alphabet:-B

B is vowel

एक टिप्पणी भेजें

0 टिप्पणियाँ