358 Programming and Data Structures
OUTPUT:
Enter Three Numbers.: 54 7
7 is the larger number.
Explanation In the above program three macros are defined. They are and (&&) , equal (= =)
and la r g e r (> ). Instead of using operators in expressions,- macros are used and result is obtained.
11.4 Write a program to create identifier for displaying double and triple of a number.
# Include <stdlo.h>
# Include <canio.h>
# define DOUBLE (a) a*2
# define TRIPLE (a) a*3
void main ()
{
int a *l;
clrscrO ;
printf ("rtSINGLE tDOUBLE tTRIPLE");
for(;a<=5;a++)
printf rn% dt% dt% d',/afDOUBLE(a)fTRIPLE(a));
1
OUTPUT
SINGLE DOUBLE TRIPLE
1 2 3
2 4 6
3 6 9
4 8 12
5 10 15
Explanation In this program we are using two identifiers DOUBLE () and TRIPLE (). They substitute
for DOUBLE () and TRIPLE () with a* 2 and a* 3 respectively. When a value is passed through these
macros their corresponding expansions are-solved.
11.3 UNDEFINING A MACRO
A macro defined with # define directives can be undefined with # unde f d irec t ive.
Syntax
#undef iden tifier
It is useful when we do not want to allow the use of macros in any portion of the program.
11.5 Write a program to undefine a macro.
# include <stdio.h>
# include <canio.h>
# define wait getche ()
void main ()
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.12.156