Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

C# Sharp Exercises: Check whether a character is an alphabet or not and if so, check for the case

C# Sharp String: Exercise-18 with Solution

Write a program in C# Sharp to check whether a character is an alphabet and not and if so, go to check for the case.

C# Sharp Exercises: Check whether a character is an alphabet or not and if so, check for the case.

Sample Solution:-

C# Sharp Code:

using System;
public class Exercise18
{
    static void Main()
    {
	
       Console.Write("\n\nCheck whether a character is alphabet or not and if so, check for case :\n");
       Console.Write("-----------------------------------------------------------------------------\n");  	
        Console.Write("Input a character: ");
        char ch = (char)Console.Read();
        if (Char.IsLetter(ch))
        {
            if (Char.IsUpper(ch))
            {
                Console.WriteLine("\nThe character is uppercase.\n");
            }
            else
            {
                Console.WriteLine("\nThe character is lowercase.\n");
            }
        }
        else
        {
            Console.WriteLine("\nThe entered character is not an alphabetic character.\n");
        }
    }
}

Sample Output:

Check whether a character is alphabet or not and if so, check for case :                                      
-----------------------------------------------------------------------------                                 
Input a character: a                                                                                          
The character is lowercase.

Flowchart:

Flowchart: Check whether a character is alphabet or not and if so, check for case.

C# Sharp Code Editor:

Contribute your code and comments through Disqus.

Previous: Write a program in C# Sharp to search the position of a substring within a string.
Next: Write a program in C# Sharp to find the number of times a substring appears in the given string.

What is the difficulty level of this exercise?

Test your Programming skills with w3resource's quiz.