endif in c

C #if and #endif preprocessor directive

An expression which is followed by the #if is evaluted, if result is non zero then the statements between #if and #endif are compiled, otherwise thay are skipped, this syntax is

if constant_expression
…………
statements
……….
……….

#endif

The constant expression should be an intergral expression and this should not contain sizeof operator,enum,cast operator or any keywords or variables. it can contains only arithmetic,logical,relational operators.

/* program to understand the use of #if directive */
#include<stdio.h>
#define
COUNT 10
int main()
{
int a=6,b=7;
#if COUNT<=12
printf("The value of COUNT is less than or equal to 12 ");
a=a+b;
b=a*b;
printf("values of variables a and b changed");
#endif
printf("a=%d and b=%d \n",a,b);
printf("program complete");
return 0;
}

output:
The value of COUNT is less than or equal to 12
values of variables a and b changed
a=13 and b=42
program complete

in the above example COUNT is defined with the value 10 . firstly the constant expression COUNT<=12 is evaluated so it is true(non zero) then all statements between #if and #endif are compiled.