Monday 26 August 2013

Simple If -else condition program in C#

Q:- In the following example, you enter a character from the keyboard, and the program uses a nested if statement to determine whether the input character is an alphabetic character. If the input character is an alphabetic character, the program checks whether the input character is lowercase or uppercase. A message appears for each case?????

Ans:- using System;
using System.Collections.Generic;
using System.Text;

namespace codeforevenorodd
{
    class Program
    {
        static void Main(string[] args)
        {
           Console.Write("Enter a character: ");
char c = (char)Console.Read();
if (Char.IsLetter(c))
{
    if (Char.IsLower(c))
    {
        Console.WriteLine("The character is lowercase.");
    }
    else
    {
        Console.WriteLine("The character is uppercase.");
    }
}
else
{
    Console.WriteLine("The character isn't an alphabetic character.");
}

Console.ReadKey();
              
            }
       
     

        }
      
        }
   
 

No comments:

Post a Comment