Write C# Program to check entered character vowel or consonant

Write C# Program to check entered character vowel or consonant


Introduction

Write C# Program to check entered character vowel or consonant. 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 charpexercise
  4. {
  5. static void Main(string[] args)
  6. {
  7. char ch;
  8.  
  9. Console.WriteLine("Enter any character: ");
  10. ch = Convert.ToChar(Console.ReadLine());
  11.  
  12.  
  13. // Condition for vowel checking
  14. if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u' || ch == 'A' || ch == 'E' || ch == 'I' || ch == 'O' || ch == 'U')
  15. {
  16.  
  17. Console.WriteLine(ch + " is Vowel.");
  18.  
  19. }
  20. else if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
  21. {
  22. Console.WriteLine(ch + " is Consonant.");
  23. }
  24.  
  25. Console.ReadLine();
  26. }
  27. }

Result

C# language techstudy.org

     





Related Topics




Popular Posts