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


Introduction

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

techstudy.org

Kindle Paperwhite High Resolution Display Tablet | Rs. 9999

  1. using System;
  2.  
  3. class Program
  4. {
  5.  
  6. static void Main(string[] args)
  7. {
  8.  
  9. char gender;
  10.  
  11. //Reading gender from user
  12. Console.WriteLine("Enter gender (M/m or F/f): ");
  13. gender = Convert.ToChar(Console.ReadLine());
  14.  
  15.  
  16. // checking vowel and consonant
  17. switch (gender)
  18. {
  19. case 'M':
  20. case 'm': Console.WriteLine("MALE");
  21. break;
  22.  
  23. case 'F':
  24. case 'f': Console.WriteLine("FEMALE");
  25. break;
  26.  
  27. default: Console.WriteLine("Unspecified Gender");
  28. break;
  29. }
  30.  
  31. Console.ReadLine();
  32.  
  33. }
  34.  
  35. }

Result

C# language techstudy

     





Related Topics


Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.