Wednesday, May 18, 2016

C# Program to Convert Lower case Alphabet to Upper case


Program to Convert Lower case Alphabet to Upper caseProgram Statement:Write a program which converts the 1 lowercase letter (‘a’ – ‘z’) in its correspondinguppercaseletter (‘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.RdLine());
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 Plse enter a small letter!\n");
}
}
static void Main(string[] args)
{
convert c1 = new convert();
Console.Clr();
Console.WriteLine("\n\n\t\t..........................................");
Console.WriteLine("\t\t\t\t Problem # 1");
Console.WriteLine("\t\t..........................................");
c1.con();
Console.Rd();
}

No comments:

Post a Comment