Objective
Write a C# program to ask the user for a symbol and respond if it's a vowel (in lowercase), a digit, or any other symbol, using "if".
Write Your C# Exercise
C# Exercise Example
using System; // Import the System namespace to use basic classes like Console
class Program // Define the main class of the program
{
static void Main() // The entry point of the program
{
// Ask the user to enter a symbol
Console.Write("Enter a symbol: "); // Display prompt for symbol input
char symbol = Console.ReadKey().KeyChar; // Read a single character input from the user
// Move to the next line after the symbol input
Console.WriteLine();
// Check if the symbol is a vowel
if (symbol == 'a' || symbol == 'e' || symbol == 'i' || symbol == 'o' || symbol == 'u') // If the symbol is a vowel
{
Console.WriteLine("It is a vowel."); // Display message for vowel
}
// Check if the symbol is a digit
else if (symbol >= '0' && symbol <= '9') // If the symbol is a digit (from '0' to '9')
{
Console.WriteLine("It is a digit."); // Display message for digit
}
else // If the symbol is neither a vowel nor a digit
{
Console.WriteLine("It is another symbol."); // Display message for other symbols
}
}
}