Thursday, April 2, 2020

c program to check whether a character is uppercase or lowercase alphabet

c program to check whether a character is uppercase or lowercase alphabet 

#include 
int main()
{
    char c; // enter character value
    printf("Enter u to display uppercase alphabets.\n"); // U for uppcase
    printf("Enter l to display lowercase alphabets. \n"); // I for lowercase
    scanf("%c", &c); // storing values

    if (c == 'U' || c == 'u') 
     {
        for (c = 'A'; c <= 'Z'; ++c)
            printf("%c ", c);
     } else if (c == 'L' || c == 'l') 
 
     {
     for (c = 'a'; c <= 'z'; ++c)
            printf("%c ", c);
     } else 
 
     {
        printf("Error! You entered an invalid character.");
     }

    return 0;
}
Output


Enter u to display uppercase alphabets 
Enter l to display lowercase alphabets = I
a b c d e f g h i j k l m n o p q r s t u v w x y z 
Happy Coding

Thanks for visiting my Blog.

Have any problem, feel free to contact us via Email : uoslondy@gmail.com

Have a good day!
Location: Pakistan

0 comments:

Post a Comment

Recent Posts