C Language = To check if a character is in Uppercase, Lowercase, number, or a Special character
To check if a character is in Uppercase, Lowercase, number, or a Special character
#include<stdio.h>
void main()// doesn't expect any return
{
int a;//initialise variable
char ch;// initialise character
printf("enter a alphabet\n");// print
scanf("%c",&a);// scan user input
if ((a>='a') && (a<='z'))// for lowercase a to z
{
printf("it is a lowercase %c",a);// print
}
else if ((a>='A')&&(a<='Z'))//for upper case A to Z
{
printf("it is an upercase %c",a); //print
}
else if ((a>='0')&&(a<='9'))//for numbers
{
printf("it is a number %c",a); //print
}
else
{printf("it is a special character %c",a);}// for special characters
}
Comments
Post a Comment