C#: Check a input is a vowel, a digit, or any other symbol
Write a C# Sharp program that takes a character as input and checks if it is a vowel, a digit, or any other symbol.
Sample Solution:-
C# Sharp Code:
using System;
public class Exercise9
{
public static void Main()
{
// Declare a variable to store the symbol entered by the user
char symbol;
// Input a symbol from the user
Console.Write("Input a symbol: ");
symbol = Convert.ToChar(Console.ReadLine());
// Check if the entered symbol is a lowercase vowel
if ((symbol == 'a') || (symbol == 'e') || (symbol == 'i') ||
(symbol == 'o') || (symbol == 'u'))
{
Console.WriteLine("It's a lowercase vowel.");
}
// Check if the entered symbol is a digit
else if ((symbol >= '0') && (symbol <= '9'))
{
Console.WriteLine("It's a digit.");
}
// If the entered symbol doesn't match the above conditions, it's another symbol
else
{
Console.Write("It's another symbol.");
}
}
}
Sample Output:
Input a symbol: a It's a lowercase vowel.
Visual Presentation:
Flowchart:

Go to:
PREV : Write a C# Sharp program that takes the radius of a sphere as input and calculate and display the surface and volume of the sphere.
NEXT :
Write a C# Sharp program that takes two numbers as input and returns true or false when both numbers are even or odd.
C# Sharp Practice online:
Contribute your code and comments through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.