upper case and lower case program in C

In this, we are going to write a simple program to check whether the given character is in UPPER or lower case or if it is an invalid character with the help of the C programming language.

#include <stdio.h>

void main()
{
    char ch;
    printf("Enter character to find if it's UPPER / lower case\n");
    scanf("%c", &ch);
    // to check if character entered is an alphabet
    // with help of ascii values of alphabets
    if (((int)ch >= 97 && (int)ch <= 122) || ((int)ch >= 65 && (int)ch <= 90))
    {
        // if character is actually alphabet
        if (((int)ch >= 97 && (int)ch <= 122))
        {
            printf("You entered LOWER case %c", ch);
        }
        else
        {
            printf("you entered UPPER case %c", ch);
        }
    }
    else
    {
        printf("INVALID character");
    }
}

#ENJOY CODING

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post