Write C# program to check vowel or consonant using switch case


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

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. using System;
  2.  
  3. class Program
  4. {
  5.  
  6. static void Main(string[] args)
  7. {
  8.  
  9. char ch;
  10.  
  11. //Reading an alphabet from user
  12. Console.WriteLine("Enter any alphabet: ");
  13. ch = Convert.ToChar(Console.ReadLine());
  14.  
  15.  
  16. // checking vowel and consonant
  17. switch (ch)
  18. {
  19. case 'a': Console.WriteLine("vowel");
  20. break;
  21. case 'e': Console.WriteLine("vowel");
  22. break;
  23. case 'i': Console.WriteLine("vowel");
  24. break;
  25. case 'o': Console.WriteLine("vowel");
  26. break;
  27. case 'u': Console.WriteLine("vowel");
  28. break;
  29. case 'A': Console.WriteLine("vowel");
  30. break;
  31. case 'E': Console.WriteLine("vowel");
  32. break;
  33. case 'I': Console.WriteLine("vowel");
  34. break;
  35. case 'O': Console.WriteLine("vowel");
  36. break;
  37. case 'U': Console.WriteLine("vowel");
  38. break;
  39. default: Console.WriteLine("consonant");
  40. break;
  41. }
  42.  
  43. Console.ReadLine();
  44.  
  45. }
  46.  
  47. }

Result

C# language techstudy

     





Related Topics




Popular Posts