Write a 'C' program to write a macro definition for the following i) To test whether a character is a lower case letter or not. ii) To check whether a character is alphabet or not. iii) To obtain the largest of two numbers.


#include<stdio.h>

#define ISUPPER(x) (x &gt;= 65 &amp;&amp; x &lt;= 90  ? 1 : 0)
#define ISLOWER(x) (x &gt;= 97 &amp;&amp; x &lt;= 122 ? 1 : 0)
#define ISALPHA(x) (ISUPPER(x) || ISLOWER(x))
#define BIG(x,y) (x &gt; y ? x : y)

void main()
{
    char ch;
    int  d,a,b;
    clrscr();
    printf("ENTER ANY CHARACTER OR ALPHABET\n");
    scanf("%c",&amp;ch);
    if((d = ISUPPER(ch)) == 1)
    {
        printf("\nYOU ENTERED A CAPITAL LETTER.");
    }
    else if((d = ISLOWER(ch)) == 1)
    {
        printf("\nYOU ENTERED A SMALL LETTER.");
    }
    else if((d = ISALPHA(ch)) != 1)
    {
        printf("\nYOU ENTERED CHARACTER IS NOT ALPHABET.");
    }
    printf("\nENTER ANY 2 NUMBERS::&gt;\n ");
    scanf("%d%d",&amp;a,&amp;b);
    d = BIG(a,b);
    printf("\nBIGGER NUMBERS::&gt; %d",d);
    getch();
}
/*OUTPUT::
ENTER ANY CHARACTER OR ALPHABET
A

YOU ENTERED A CAPITAL LETTER.
ENTER ANY 2 NUMBERS::&gt;
 3 2

BIGGER NUMBERS::&gt; 3
ENTER ANY CHARACTER OR ALPHABET
g

YOU ENTERED A SMALL LETTER.
ENTER ANY 2 NUMBERS::&gt;
 6 4

BIGGER NUMBERS::&gt; 6
Write a 'C' program to write a macro definition for the following i) To test whether a character is a lower case letter or not. ii) To check whether a character is alphabet or not. iii) To obtain the largest of two numbers. Write a 'C' program to write a macro definition for the  following  i) To test whether a character is a lower case letter or not.  ii) To check whether a character is alphabet or not.  iii) To obtain the largest of two numbers. Reviewed by on April 24, 2015 Rating: 5
Powered by Blogger.