# Write a macro to find the smallest number among 3 given numbers. 7m Jun2007

By | August 4, 2015

Write a macro to find the smallest number among 3 given numbers. 7m Jun2007

Code:

#include<stdio.h>

#define MIN(X,Y)(X<Y ? X:Y)
#define SMALL(X,Y,Z)(MIN(X,Y)<Z ? MIN(X,Y):Z)

void main()
{
int FIRST,SECOND,THIRD;
clrscr();
printf(“ENTER NUMBERS TO COMPARE\n”);
printf(“\nFIRST NUMBER : “);
scanf(“%d”, &FIRST);
printf(“\nSECOND NUMBER : “);
scanf(“%d”, &SECOND);
printf(“\nTHIRD NUMBER : “);
scanf(“%d”, &THIRD);
printf(“\nThe SMALLER NUMBER IS : %d”, SMALL(FIRST,SECOND,THIRD));
getch();
}

 Source code
```#include<stdio.h>
#define MIN(X,Y)(X<Y ? X:Y)
#define SMALL(X,Y,Z)(MIN(X,Y)<Z ? MIN(X,Y):Z)
void main()
{
int FIRST,SECOND,THIRD;
clrscr();
printf("ENTER NUMBERS TO COMPARE\n");
printf("\nFIRST NUMBER : ");
scanf("%d", &FIRST);
printf("\nSECOND NUMBER : ");
scanf("%d", &SECOND);
printf("\nTHIRD NUMBER : ");
scanf("%d", &THIRD);
printf("\nThe SMALLER NUMBER IS : %d", SMALL(FIRST,SECOND,THIRD));
getch();
}```

Screen Shots:

2(a) Write the usage of the following (with an example of each): 5m Dec2008

i)              #define

Solved program can be found on this link http://www.techonthenet.com/c_language/constants/create_define.php

ii)             Enurn

Solved program can be found on this link http://www.programiz.com/c-programming/c-enumeration