C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C #ifdefThe #ifdef preprocessor directive checks if macro is defined by #define. If yes, it executes the code otherwise #else code is executed, if present. Syntax: #ifdef MACRO //code #endif Syntax with #else: #ifdef MACRO //successful code #else //else code #endif C #ifdef exampleLet's see a simple example to use #ifdef preprocessor directive. #include Output: Value of a: 2 But, if you don't define NOINPUT, it will ask user to enter a number. #include Output: Enter a:5 Value of a: 5
Next TopicC #ifndef
|