C #if:
The #if is a preprocessor directive in C which is used to execute a piece of code, only if the specified condition is TRUE.
Syntax:
#if condition
// code to be executed if condition is TRUE.
#endif
OR
#if condition
// code to be executed if condition is TRUE.
#else
// code to be executed if condition is FALSE.
#endif
Example:
#include<stdio.h> #define AGE 30 void main() { #if (AGE==30) printf("Value of AGE is correct."); #else printf("Wrong value of AGE."); #endif } |
Output
Value of AGE is correct. |