Follow these steps to perform conditional compilation with preprocessor directives:
- Define a Qty macro and assign it an initial value:
#define Qty 10
- The user will be prompted to enter the price of a book:
printf("Enter price of a book ");scanf("%f", &price);
- The total number of books is computed using the Qty*price formula:
totalAmount=Qty*price;
- On the basis of the Qty macro, the #if, #elif, #else, and #endif directives are used to determine the discount on the total number.
- Once the discount percentage is determined, the amount after deducting the discount is computed and is assigned to the afterDisc variable:
afterDisc=totalAmount - (totalAmount*discount)/100;
- The festival discount is also computed on the ...