ifelse

The ifelse directive lets us specify the action if the condition is not true.

Example

#define UKP 1
 
#include <stdio.h>

 
#if (defined (USD))            // B
         #define currency_rate 46
#else
        #define currency_rate 100             //C
#endif                          //D
 
int main()
{
    int rs;
    rs = 10 * currency_rate;    //H
    printf ("%d\n", rs);
    getchar();
    return ;
}

Explanation

  1. Statement B indicates the ifelse directive.
  2. If the identifier USD is defined, the currency rate is taken as 46; otherwise, the currency rate is taken as 100.
  3. Since USD is not defined, the currency rate is taken as 46.

Point to Remember

  1. The ifelse directive allows us to take action if the condition is not satisfied.