Wednesday, May 18, 2016

C# Program to check character is capital, small, digit or special symbol


Program to take one character from user and determine whether the entered character is a capital letter, a small case letter, a digit or a special symbol

Program Statement:
Write a program which take one character from user and determine whether the character entered is a capital letter, a small case letter, a digit or a special symbol.

Solution:static void Main(string[] args)
{
char ch;
int a;
Console.WriteLine("Enter any Character:");
ch = Convert.ToChar(Console.RdLine());
a= (int)ch;
if (a >= 65 && a <= 90)
Console.WriteLine("Entered Character is in Capital Letter");
else if(a>=97 && a<=122)
Console.WriteLine("Entered Character is in Low Letter");
else if(a>=48 && a<=57)
Console.WriteLine("Entered Character is a digit");
else
Console.WriteLine("Entered Character is a Special Symbol");
Console.RdLine();
}

No comments:

Post a Comment