The conditional directives are meant to control the compilation process. By using them we may conditionally include certain statements of the program for compilation. If the condition is not met the statements are not included. These directives also help us not to include duplicate files in the program and cause error. For example, see the following code:
#ifndef Size
#define Size 6
#else
#define Size 5
#endif
It directs that if Size has not been defined already, define it as 6. However, if it has been defined irrespective of the value then take it as 5. In Program, it has been defined before though value is not given, therefore, it takes the value after the else. The #ifndef must end with #endif. The conditional preprocessor directives starting with #if must end with #endif. Program presents a good example of this concept.
#include <stdio.h> #define Size #ifndef Size #define Size 6 #else #define Size 5 #endif void main() { int y = 4 , Product; Product = Size * y; printf("Product = %d\n", Product); }