#if allows you to define more generalized conditions. Multiple conditions, which are connected by relational operators such as AND(&&), OR(||), are allowed.


#define USD 1
#define UKP 1
#include <stdio.h>
#include <conio.h>
#if ((1>0) &&(defined (USD)))      // B
       #define currency_rate 46                     //C
#endif                       //D
#if (defined (UKP))                     // E
   #define currency_rate 100 //F
#endif                       //G
int main()
    int rs;
    rs = 10 * currency_rate; //H
    printf ("%d\n", rs);

1.Statement B indicates the if directive.
2.The generalized form of the if directive is

#if <condition>

3.The condition (1>0) is absolutely not necessary here. It is given just to indicate how we can concatanate multiple conditions.
4.The condition defined (USD) is true only if the identifier USD is defined.
Points to Remember
1.The if directive allows us to use a condition more generalized than ifdef.
2.The defined() predicate returns true if the symbol is defined; otherwise, it is false.


You may also like...