Procecessor Directives : #elif

The #elif Conditional Compilation Directive allow us to include certain portion of the code depending upon the output of constant expression. It evaluates the expression or condition if condition of #if is false. The syntax is :

Syntax :
 #if Expression
   // statement to execute
 #elif
   // statement to execute
 #endif
Example :
#include <stdio.h>

#define AGE 24

int main() {

#if (AGE < 18)
  printf("You are a miner.\n"); 
#elif (AGE > 18)
  printf("You an Adult.\n");
#endif

  return 0;   
}
Output :

You an Adult.


Next : C Language Tutorials List