Preprocessor Directives 363
Hiendif
getcheO;
I
OUTPUT;
A=2 & B=3
Explanation The execution of the above program is same as the previous one. The only difference is
in the name of the identifier. Here, in this program the identifier is E. The compiler searches for the
identifier E. If it is found then execution of #i f block takes place otherwise #else block. The #end± f
statement indicates the end of # i f #endi f block.
11.7 THE #ifn d ef DIRECTIVE
The syntax of the # if ndef directive is given below.
Syntax
#ifndef <identifier>
{
statement!;
statement2;
}
#else
{
statement3;
statements
}
#endif
Th e#ifnd ef works exactly opposite to that of # ifd e f. T h e# ifn d ef preprocessor tests whether the
identifier has defined substitute text or not. If the identifier is defined then #else block is compiled and
executed and the compiler ignores # i f block even if errors are intentionally made. Error- Messages
will not be displayed. If identifier is not defined then # i f block is compiled and executed.
11.12 Write a program to check conditional compilation directives #ifndef. If it is ob&enred
display one message otherwise another message.
# Include <stdio.h>
# include ccanio. h>
# define T 8
void main ()
{
clrscrO ;
XifndefT
printf ("n Macro is not defined/');
telse
printf ("n Macro is defined/');
Hendif
I
OUTPUT:
Macro is defined.
..................Content has been hidden....................

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