www.gibmonks.com

Main Page




Previous Page
Next Page

[Page 1281 (continued)]

Self-Review Exercises

F.1

Fill in the blanks in each of the following:

  1. Every preprocessor directive must begin with ___________.

  2. The conditional compilation construct may be extended to test for multiple cases by using the ___________ and the ___________ directives.

  3. The ___________ directive creates macros and symbolic constants.

  4. Only ___________ characters may appear before a preprocessor directive on a line.

  5. The ___________ directive discards symbolic constant and macro names.

  6. The ___________ and ___________ directives are provided as shorthand notation for #if defined(name) and #if !defined(name).


  7. [Page 1282]
  8. ___________ enables the programmer to control the execution of preprocessor directives and the compilation of program code.

  9. The ___________ macro prints a message and terminates program execution if the value of the expression the macro evaluates is 0.

  10. The ___________ directive inserts a file in another file.

  11. The ___________ operator concatenates its two arguments.

  12. The ___________ operator converts its operand to a string.

  13. The character ___________ indicates that the replacement text for a symbolic constant or macro continues on the next line.

F.2

Write a program to print the values of the predefined symbolic constants __LINE__, __FILE__, __DATE__ and __TIME__ listed in Fig. F.1.

F.3

Write a preprocessor directive to accomplish each of the following:

  1. Define symbolic constant YES to have the value 1.

  2. Define symbolic constant NO to have the value 0.

  3. Include the header file common.h. The header is found in the same directory as the file being compiled.

  4. If symbolic constant TRUE is defined, undefine it, and redefine it as 1. Do not use #ifdef.

  5. If symbolic constant trUE is defined, undefine it, and redefine it as 1. Use the #ifdef preprocessor directive.

  6. If symbolic constant ACTIVE is not equal to 0, define symbolic constant INACTIVE as 0. Otherwise, define INACTIVE as 1.

  7. Define macro CUBE_VOLUME that computes the volume of a cube (takes one argument).


Previous Page
Next Page