Q:

Write C# program to print gender (Male/Female) program according to given M/F

0

Write C# program to print gender (Male/Female) program according to given M/F

All Answers

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

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability.

using System;
 
class Program
{
 
    static void Main(string[] args)
    {
 
        char gender;
 
        //Reading gender from user
        Console.WriteLine("Enter gender (M/m or F/f): ");
        gender = Convert.ToChar(Console.ReadLine());
 
 
    // checking vowel and consonant
        switch (gender)
        {
            case 'M':
            case 'm': Console.WriteLine("MALE");
            break;
 
            case 'F':
            case 'f': Console.WriteLine("FEMALE");
            break;
 
            default: Console.WriteLine("Unspecified Gender");
                break;
        }
 
        Console.ReadLine();
 
    }
 
}

Result:

Enter gender (M/m or F/f): 

M

MALE

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

total answers (1)

Write C# program to find maximum number using swit... >>
<< Write C# program to check vowel or consonant using...