C #ifdef


It is a preprocessor directive checks macro is defined by #define. If yes, it executes the code.


Syntax:

#ifdef MACRO
//source code
#endif

Example:

#include <stdio.h>    
#define NOVALUE  
void main() {  
    int i=0;  
    #ifdef NOVALUE  
        i=2;  
    #else  
        printf("Enter the Value of i is:");  
        scanf("%d", &i);  
    #endif         
    printf("The Value of i: %d\n", i);  
}



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.