Q14 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.

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.

Program: 82

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.

CharactersASCII Values
A – Z65 – 90
a – z97 – 122
0 – 948 – 57
special symbols0 – 47, 58-64, 91 – 96, 123 – 127

#include<stdio.h>
#include<conio.h>
int main()
{
    char ch;
    int ascii;
    printf("Enter a character: ");
    scanf("%c", &ch);
    ascii = ch;

    printf("ASCII value of %c is: %d\n",ch,ascii);


    //for capital characters (A to Z)
    if (ascii >= 65 && ascii <= 90)
        printf("%c is a capital letter");

    //for small characters (a to z)
    else if (ascii >= 97 && ascii <=122)
        printf("%c is a small letter");

    //for digits (0 to 9)
    else if (ascii >=48 && ascii <= 57)
        printf("%c is a digit");

    //for special symbols
    else if (ascii>=0 && ascii<=47 || ascii>=58 && ascii<=64 || ascii>=91 && ascii<=96 || ascii>=123 && ascii<=127)
        printf("%c is a special symbols");

}

Output:

 Enter a character: A
 ASCII value of A is: 65
 A is a capital letter
 
 Enter a character: 0
 ASCII value of 0 is: 48
 0 is a digit

 Enter a character: @
 ASCII value of @ is: 64
 @ is a special symbols

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.