Write a c program to demonstrate pre-processor directives conditional Compilation
#include <stdio.h>
// Define DEBUG to enable debug-specific code
#define DEBUG
// Define VERSION to switch between different versions of the code
#define VERSION 2
int main() {
printf("Conditional Compilation Demonstration\n");
#ifdef DEBUG
printf("Debug mode is enabled.\n");
#endif
#if VERSION == 1
printf("This is version 1 of the program.\n");
#elif VERSION == 2
printf("This is version 2 of the program.\n");
#else
printf("Unknown version.\n");
#endif
#ifndef DEBUG
printf("Debug mode is not enabled.\n");
#endif
return 0;
}
Comments
Post a Comment