Monday, November 28, 2016

C# Program to Convert Lower case Alphabet to Upper case

Program to Convert Lower case Alphabet to Upper case

Program Statement:

Write a program which converts the 1 lowercase letter (‘a’ – ‘z’) in its corresponding uppercase letter (‘A’ – ‘Z’). E.g. if user enter c then program will show C on the screen.

Solution:


//Program to Convert Lower case Alphabet to Upper class

class convert
{
char ch, c;
int a;
public void con()
{
Console.Write("\n\t\tEnter small letter : ");
ch = Convert.ToChar(Console.ReadLine());
a = (int)ch;
if (ch >= 97 && ch <= 122)
{
c = (char)(ch - 32);
Console.Write("\t\t Capital letter : {0}\n\n", c);

}
else
Console.WriteLine("\t\t Please enter a small letter!\n");
}
}
static void Main(string[] args)
{
convert c1 = new convert();
Console.Clear();
Console.WriteLine("\n\n\t\t..........................................");
Console.WriteLine("\t\t\t\t Problem # 1");
Console.WriteLine("\t\t..........................................");
c1.con();
Console.ReadKey();
}