Write a macro to find out whether the given character is lower case or not 7m Dec2008

By | April 17, 2016

Write a macro to find out whether the given character is lower case or not 7m Dec2008

3. (a) Write a macro to find out whether the given character is lower case or not. 7

#include <stdio.h>

//#define IS_UPPER_CASE(n) ((n) >= ‘A’ && (n) <= ‘Z’)
#define IS_LOWER_CASE(n) ((n) >= ‘a’ && (n) <= ‘z’)

//#define IS_ALPHABETIC(n) (IS_UPPER_CASE(n) || IS_LOWER_CASE(n))

void main()
{
char CH=’a’;
clrscr();
if(IS_LOWER_CASE(CH))
printf(“\nYES, CHARACTER IS A LOWER CASE CHARACTER”);
else
printf(“\nNO, CHARACTER IS NOT A LOWER CASE CHARACTER”);
getch();
}

Code:-

 

[codesyntax lang=”c”]

#include <stdio.h>

//#define IS_UPPER_CASE(n) ((n) >= 'A' && (n) <= 'Z')
#define IS_LOWER_CASE(n) ((n) >= 'a' && (n) <= 'z')

//#define IS_ALPHABETIC(n) (IS_UPPER_CASE(n) || IS_LOWER_CASE(n))

void main()
{
char CH='a';
clrscr();
if(IS_LOWER_CASE(CH))
printf("\nYES, CHARACTER IS A LOWER CASE CHARACTER");
else
printf("\nNO, CHARACTER IS NOT A LOWER CASE CHARACTER");
getch();
}

[/codesyntax]

 

Screenshot:-

C_program_Macro_Lower_Case

C_program_Macro_Lower_Output