Preprocessor Directives II-259
“# undef wait getche()”, then the compiler does not show any error and the output displayed on the
screen would be “1 2 3 4 5”.
19. What is an assert() macro?
Ans: An assert macro is defined assert.h header file. This macro tests the value of an expression.
If the expression contains false value, assert displays error message and executes the function abort() to
abort the program execution.
20. Write a program on an assert() macro.
Ans:
#include <assert.h>
void main()
{
int x=4;
clrscr();
assert(x!=4);
printf("%d",x);
}
OUTPUT:
Assertion failed: x!=4, file AMITPOINTERE.C, line 7
Abnormal program termination
Explanation: In this program, the value of x is 4. The assert() macro checks the value of x. If the
condition is false, the macro executes abort() and the program is terminated.
Multiple-choice Questions
1. Consider the statement #define PI 3.14, it means .
(a) Every occurrence of PI (identifier) is replaced with 3.14 (substitute value)
(b) Occurrence of PI only in expressions is replaced with 3.14
(c) None of the above
2. A macro defined with # define directives can be undefined with .
(a) #undef directive (b) #ifndef (c) #!def
3. The file name is included in the double quotations marks indicates that .
(a) The search for the file is to be made in the current directory and in the standard directories
(b) The search for the file is to be made in the current directory
(c) The search for the file is to be made in the entire system
4. When the file name is included without double quotation marks and when program is executed, the
message appears on the screen will be .
(a) The search for file is made only in the standard directories
(b) The search for file is made only in the current directory
(c) The search for the file is to be made in the entire system
(d) Bad file name format in include directory
M12_ITL-ESL4791_02_SE_C12.indd 259 12/22/2012 5:05:48 PM