w3resource
C# Sharp Programming Exercises

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?



New Content: Composer: Dependency manager for PHP, R Programming