Enter the Character : a The Character is : A
Users Online
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Latest Articles
Articles Hierarchy
C# Program to Convert Lowercase Characters by Uppercase and Vice-Versa
C# Program to Convert Lowercase Characters by Uppercase and Vice-Versa
This is a C# Program to obtain the character from the user and convert the case of the character.
This C# Program Obtains the Character from the User and Convert the Case of the Character.
Here the user enters the character and the uppercase letters are converted to lowercase and vice versa.
Here is source code of the C# Program to Obtain the Character from the User and Convert the Case of the Character. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Obtain the Character from the User and Convert * the Case of the Character */ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace casechange { class Program { static void Main(string[] args) { char a; int i; Console.WriteLine("Enter the Character : "); a = Convert.ToChar(Console.ReadLine()); i=(int)a; if (a >= 65 && a <= 90) { Console.WriteLine("The Character is : {0}", char.ToLower(a)); } else if (a >= 97 && a <= 122) { Console.WriteLine("The Character is : {0}", char.ToUpper(a)); } Console.ReadLine(); } }
In this C# program, we are reading the character using ‘a’ variable. Nested else if condition statement is used to check the value of ‘a’ variable is greater than or equal to 65 and less than or equal to 90 by using logical AND operator.
If the condition is true then execute the statement. Convert the character to lowercase using toLower() function. Otherwise, if the condition is false then execute else if condition statement. Check the value of character string is lower case. If the condition is true then execute the statement. Convert the character to upper case using ToUpper() function.