w3resource
C# Sharp Programming Exercises

C# Sharp Exercises: Check a input is a vowel, a digit, or any other symbol


C# Sharp Basic Data Types: Exercise-9 with Solution

Write a C# Sharp program that takes a character as input and check the input (lowercase) is a vowel, a digit, or any other symbol.

Sample Solution:-

C# Sharp Code:

using System;
public class Exercise9
{
    public static void Main()
    {
        char symbol;
         
        Console.Write("Input 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.");        
    }
}

Sample Output:

Input a symbol: a                                                                                             
It's a lowercase vowel.  

Flowchart:

Flowchart: Check a input is a vowel, a digit, or any other symbol.

C# Sharp Practice online:

Contribute your code and comments through Disqus.

Previous: 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.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming