google.com, pub-4617457846989927, DIRECT, f08c47fec0942fa0 Learn to enjoy every minute of your life.Only I can change my life.: C program to write a macro definition

Wednesday, April 1, 2015

C program to write a macro definition

Write a ‘C’ program to write a macro definition for the following.
> To test whether a character is a lower case letter or not.
> To check whether a character is alphabet or not.
> To obtain the largest of two numbers.

#include<stdio.h>
#include<conio.h>
#define LOWER(ch) islower(ch)
#define ALPHA(ch) isalpha(ch)
#define MAX(a,b) a>b?a:b
void main()
{
int n,a,b;
char c;
clrscr();
do
{
printf("\n1.LOWER");
printf("\n2.ALPHABET");
printf("\n3.MAXIMUM");
printf("\n4.EXIT");
printf("\nENTER UR CHOICE");
scanf("%d",&n);
switch(n)
{
case 1:
printf("\nENTER THE CHARACTER");
c=getche();
if(LOWER(c))
{
printf("\nCHARACTER IS IN LOWERCASE\n");
}
else
{
printf("\nCHARACTER IS IN UPPERCASE");
}
break;
case 2:
printf("\nENTER THE CHARACTER");
c=getche();
if(ALPHA(c))
{
printf("\nCHARACTER IS ALPHABET");
}
else
{
printf("CHARACTER IS NOT ALPHABET");
}
break;
case 3:
printf("\nENTER THE VALUES FOR A AND B");
scanf("%d%d",&a,&b);
  if(MAX(a,b))
{
printf("A IS MAXIMUM");
}
else
{
printf("B IS MAXIMUM");
}
break;
case 4:
exit(0);
}
}
while(n!=4);
getch();
}

अच्छे विचार करे विचार

  पहचान की नुमाईश, जरा कम करें... जहाँ भी "मैं" लिखा है, उसे "हम" करें... हमारी "इच्छाओं" से ज़्यादा "सुन...