Performing conditional compilation with directives

In this recipe, we will learn how to apply conditional compilation. We will define certain macros, and then, by applying theĀ #if, #ifdef, #ifndef, #else, #elif, #endif, and #undef preprocessor directives, we will direct the compiler to compile the desired code. Considering the example of a bookstore, let's assume that a user is asked to enter the price of the book. The program will apply different discounts, festival offers, a discount coupon, and Kindle options on the basis of theĀ Qty macro, which represents the quantity or number of books purchased by the user. The program also defines other macros that determine different offers that are applicable.