Labels

Wednesday, December 23, 2015

Largest of three numbers using Macro;

A C program to find the largest of three numbers using macro;

#include
#define CONDITION if (b>=97 && b<=122)\
printf("The character u entered is a small alphabet.\n");\
else\
{\
if(b>=65 && b<=112)\
printf("The character you entered is a large alphabet.\n");\
else\
printf("You have not entered a alphabet.\n");\
}
int main()
{
char a;
printf("Enter any character: ");
a= getchar();
int b= a;
CONDITION;
return 0;

}

Largest of three using Macro
















To compile this program in Linux:
  1. Save this file with extension .c
  2. g++ compiler come pre installed in linux. Type this in terminal g++ display.c -o display. Here, I have assumed that the file name is display.c. -o array will provide me with an output file with extension exe file and name display.
  3. Now, run this file typing ./display and press enter.
To compile this program using cmd:
  1. Save this file with extension.c
  2. Type this in the cmd g++ display.c -o display.
  3. To run type display and press enter.
Note: To use g++ compiler in windows user has to install these compiler by itself as g++ compiler does not come per installed in windows operating system.




No comments:

Post a Comment