360 Programming and Data Structures
DOUBLE(m);
TRIPLE(tn);
getcheO;
I
o s m j m
Enter a number: 5
Double of m =10
Triple of m =15
Explanation In the above program the value o f 'm' is passed to DOUBLE () and TRIPLE () macros
which is assigned to x . "#x" prints the name of the variable passed through the macros.
11.8 Write a program to find the larger of the two numbers using macro with arguments.
# include <stdio.h>
# include <canio.h>
# define MAX (x,y) i f (x>y) c=x; else c=*y;
void mainO
{
int xยป5#y=8/c;
c lrsc r O ;
M A X (x ,y );
printf ("tt Larger o f two numbers = % d",c);
}
OUTPUT:
Larger of two numbers = 8
Explanation In the above program macro MAX ( ) is defined with two arguments x and y . When a
macro is called, its corresponding expression is executed and result is displayed. The expression
contains i f statement that determines the largest number and assigns it to variable c.
11.5 THE# include DIRECTIVE
The # include directive loads specified file in the current program. The macros and functions of
loaded file can be called in the current program. The included file is also compiled with current
program. The syntax is as given below.
a) # include "filename"
b) # include < fileame>
Where, # is a symbol used with directives.
a) The file name is included in the double quotation marks which indicates that the search for the
file is made in the current directory and in the standard directories.
Example # include "stdio.h"
..................Content has been hidden....................

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