Q:

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

0

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.
Test Data :
Input a character: Z

Expected Output :

The character is uppercase.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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");
        }
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now