Experiments-2

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>

void main()
{
 char ch;

 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");
 }

}

OUTPUT-1 :
__________

Enter a Character : H
Upper case letter


OUTPUT-2 :
__________

Enter a Character : g
Lower case letter


OUTPUT-3 :
__________

Enter a Character : 8
Digit


OUTPUT-3 :
__________

Enter a Character : 8
Special Symbol


No comments:

Post a Comment

Note: only a member of this blog may post a comment.