write a program to accept a character and dertermine it is alphabet or a digit
Answers
Answer:
Write a program to accept a character and dertermine it is alphabet or a digit .
Write a C program to input a character from user and check whether given character is alphabet, digit or special character using if else. How to check if a character is alphabet, digits or any other special character using if else in C programming. Logic to check alphabet, digit or special character in C programming.
- Write a program to accept a character and determine it is alphabet or a digit.
- The source code is written in java language.
class Program
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a character: ");
char a=sc.next().charAt(0);
if(a>='0' && a<='9')
System.out.println("Given character is a number. ");
else if(a>='a' && a<='z' && a>='A' && a<='Z')
System.out.println("Given character is an alphabet. ");
else
System.out.println("Given character is neither a digit nor an alphabet. ");
}
}