
Preprocessor Directives II-257
The
#ifdef preprocessor tests whether the identifier has defined substitute text or not. If the identifier
is defined, then #if block is compiled and executed. The compiler ignores #else block even if errors are
intentionally made. Error messages will not be displayed. If identifier is not defined, then #else block
is compiled and executed.
13. Write a program with conditional compilation statement.
Ans:
#define LINE 1
void main()
{
clrscr();
#ifdef LINE
printf("This is line number one.");
#else
printf("This is line number two.");
#endif
getche();
}
OUTPUT:
This is line number one.
Explanation: In the above program, #ifdef ...