Conditional Compilation using #if #else #elif #endif C Pre Procesor Directives

Source code for this Tutorial


#include <stdio.h>
#include <stdlib.h>

#define INDIA 1
#define US 2
#define PAK 3
#define OTHER 4

#define COUNTRY INDIA

#define AGE 18

int main()
{

printf("Code for the Universe\n");

#if COUNTRY == INDIA
    printf("Code for the Indians\n");
    #if AGE >= 18
        printf("i'm adult");
    #else
        printf("I'm minor");
    #endif

#elif COUNTRY == US
    printf("Code For the Us\n");
#elif COUNTRY == PAK
    printf("Code for PAK\n");
#else
    printf("Code for Other countries\n");
#endif // COUNTRY


    return 0;
}