Programming Course in C# ¡Free!

Vowel - if

 Saturday, April 06, 2013 published by Exercises C#
Proposed exercise

Create a program to ask the user for a symbol and answer if it is a (lowercase) vowel, a digit, or any other symbol, using "if".


Output



Solution


using System;
public class Vowel
{
public static void Main()
{
char symbol;

Console.Write("Enter a symbol: ");
symbol=Convert.ToChar(Console.ReadLine());

if ((symbol == 'a') || (symbol == 'e') || (symbol == 'i') || 
(symbol == 'o') || (symbol == 'u'))
Console.WriteLine("It's a lowercase vowel.");
else if ((symbol >= '0') && (symbol <= '9'))
Console.WriteLine("It's a digit.");
else
Console.Write("It's another symbol.");        
}
}