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
- Statement B indicates the ifelse directive.
- If the identifier USD is defined, the currency rate is taken as 46; otherwise, the currency rate is taken as 100.
- Since USD is not defined, the currency rate is taken as 46.
Point to Remember
- The ifelse directive allows us to take action if the condition is not satisfied.