How to check lowercase or uppercase using macro in C

1 Answer

0 votes
#include <stdio.h>

#define IS_UPPER(ch) (ch >= 'A' && ch <= 'Z')
#define IS_LOWER(ch) (ch >= 'a' && ch <= 'z')

int main()
{
    char ch = 'z';

    if (IS_UPPER(ch))
        printf("Uppercase");
    else if (IS_LOWER(ch))
        printf("Lowercase");
    else 
        printf("Character is not alphabet");

    return 0;
}




/*
run:

Lowercase

*/

 



answered Apr 18, 2022 by avibootz
...