Thursday, 25 June 2015

Write a C# program to display whether the input character is a digit or alphabet

using System;

class Pro
{
    static void Main()
    {
        char ch;
        Console.WriteLine("Enter your input: ");
        ch = Convert.ToChar(Console.ReadLine());
        if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'))
            Console.WriteLine("You have entered an alphabet");
        else if (ch >= '0' && ch <= '9')
            Console.WriteLine("You have entered a digit");
        else
            Console.WriteLine("You have entered a special character");
    }
}

No comments:

Post a Comment