Write C# Program to Check whether an alphabet is a vowel or not

Write C# Program to Check whether an alphabet is a vowel or not


Introduction

Write C# Program to Check whether an alphabet is a vowel or not. 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. public class exercise17
  4. {
  5. static void Main(string[] args)
  6. {
  7. char ch;
  8.  
  9. Console.Write("Input an Alphabet (A-Z or a-z) : ");
  10. ch = Convert.ToChar(Console.ReadLine().ToLower());
  11. int i = ch;
  12. if (i >= 48 && i <= 57)
  13. {
  14. Console.Write("You entered a number, Please enter an alpahbet.");
  15. }
  16. else
  17. {
  18. switch (ch)
  19. {
  20. case 'a':
  21. Console.WriteLine("The Alphabet is vowel");
  22. break;
  23. case 'i':
  24. Console.WriteLine("The Alphabet is vowel");
  25. break;
  26. case 'o':
  27. Console.WriteLine("The Alphabet is vowel");
  28. break;
  29. case 'u':
  30. Console.WriteLine("The Alphabet is vowel");
  31. break;
  32. case 'e':
  33. Console.WriteLine("The Alphabet is vowel");
  34. break;
  35. default:
  36. Console.WriteLine("The Alphabet is not a vowel");
  37. break;
  38. }
  39. }
  40. Console.ReadLine();
  41. }
  42. }

Result

C# language techstudy.org

     





Related Topics




Popular Posts