Tuesday, March 29, 2016

#If




Normally it is used to add or delete some parts of code based on a certain condition.
The #if only deals with definition as it is evaluated before the compilation of the program.


Example :-


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
#include <stdio.h>
#include <stdlib.h>
#define log 0
int main()
{
    int x =1 ;
    printf("%d\n",x);
    #if (log ==1)
    printf("Hello world!\n");
    #else
    printf("Hello Earth\n");
    #endif // log
    return 0 ;

}




Share this

0 Comment to "#If"

Post a Comment