click on this link......

LinkGrand.com
Showing posts with label small case letter. Show all posts
Showing posts with label small case letter. Show all posts

Tuesday, 10 September 2013

To find whether character entered is capital letter, small case letter,a digit or a special symbol

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. The following table shows the range of ASCII values for various characters.

Characters                     ASCII VAlues
A-Z                                65-90
a-z                                  97-122
0-9                                 48-57
Special symbols               0-47, 58-64, 91-96, 123-127

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
clrscr();
printf("Enter a character:");
scanf("%c",&ch);
if(ch>=65 && ch<=90)
{
printf("\n Upper case letter");
}
else if(ch>=97 && ch<=122)
{
printf("\n Lower case letter");
}
else if(ch>=48 && ch<=57)
{
printf("\n Digit");
}
else if((ch>=0 && ch<=47) || (ch>=58&& ch<=64) || (ch>=91 && ch<=96) || (ch>=123 && ch<=127))
{
printf("\n Special symbol");
}
getch();
}

Output1:

Enter a Character: H
Upper case letter

Output2:

Enter a Character: g
Lower case letter

Output3:

Enter a Character: 8
Digit

Output4:

Enter a Character: @
Special symbol