[1/2] Detection of Character using ASCII (Logical Operators)

This program detects whether the character entered is a Small letter, capital letter, a number or a special Symbol. This can be done by comparing each of the character with its corresponding ASCII Value.

Any character is entered through the keyboard, write a program to determine whether the
character entered is a capital letter, a small case letter, a digit or a special symbol.



#include<stdio.h>
main()
{
char charac;

printf ("Enter the character to be checked for: ");
scanf("%c", &charac);

if ((charac>=65) && (charac<=95))

{
printf("The entered character is a Capital(Upper Case) Letter");
}
else if ((charac>=97) && (charac<=122))

{
printf("The entered character is a Small(Lower Case) Letter.");
}
else if ((charac>=48) && (charac<=57))

{
printf("The entered character is a Number");
}
else if ((charac>=0) && (charac<=47) ||(charac>=58) && (charac<=64) ||(charac>=91) && (charac<=96) ||(charac>=123) && (charac<=127))

{
printf("The entered character is a special symbol. ");
}
}




The file can be found at:
Download File

Comments

Anonymous said…
Thanks very much !!

Popular posts from this blog

C Program - Calculation of Area and Circumference of a Circle using Pointers

Matchstick Game using C Programming

Generation of Fibonacci Sequence using Recursion.