A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write C# Program to check whether a character is alphabet, digit or special character
Q:

Write C# Program to check whether a character is alphabet, digit or special character

0

Write C# Program to check whether a character is alphabet, digit or special character

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

I have used Visual Studio 2012 for debugging purpose. But you can use any version of visul studio as per your availability..

using System;
 
public class charpexercise
{
    static void Main(string[] args)
    {
        char ch;
 
        Console.WriteLine("Enter any character: ");
        ch = Convert.ToChar(Console.ReadLine());
 
        // Alphabet checking condition
        if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
        {
            Console.WriteLine(ch + "is an Alphabet. ");            
        }
        else if (ch >= '0' && ch <= '9')
        {         
            Console.WriteLine(ch + "is a Digit. ");
        }
        else
        {
            Console.WriteLine(ch + "is a Special character.. ");            
        } 
 
        Console.ReadLine();
    }
}

Result:

Enter any character: 

$

$is a Special character..

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now